Open2
【Roblox】Guiメモ #1
StarterGuiー>ScreenGuiー>Viewスクリプト
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local gui = script.Parent
-- gui上のボタンハンドリング
gui.Selection.Action.Sell.Activated:Connect(function()
end)
--ユーザーからの入力ハンドリング(キーボードやスマホタッチ)
UserInputService.InputBegan:Connect(function(input, processed)
if processed then
return
end
if towerToSpawn then
if input.UserInputType == Enum.UserInputType.MouseButton1 then
SpawnNewTower()
elseif input.UserInputType == Enum.UserInputType.Touch then
local timeSinceLastTouch = tick() - lastTouch
if timeSinceLastTouch <= 0.25 then
SpawnNewTower()
end
lastTouch = tick()
elseif input.KeyCode == Enum.KeyCode.R then
rotation += 90
elseif input.KeyCode == Enum.KeyCode.X or input.KeyCode == Enum.KeyCode.C then
RemovePlaceholderTower()
end
elseif hoveredInstance and (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) then
local model = hoveredInstance:FindFirstAncestorOfClass("Model")
if model and model.Parent == workspace.Towers then
selectedTower = model
else
selectedTower = nil
end
toggleTowerInfo()
end
end)