Again, I am making a 2048 test game and I ran into a problem when making a cube dropper. I am trying to make the dropper move but clicking a screen button and when I release the mouse button it stops, but this happens
here is the script.
local Button = script.Parent
local Dind = game.Workspace.Drops.DropIndicator
local Box = game.Workspace.Drops.Box
Button.MouseButton1Down:Connect(function()
repeat
Dind.Position = Vector3.new(Dind.Position.X, Dind.Position.Y, Dind.Position.Z + .1)
wait(.01)
until Button.MouseButton1Up == true
end)
local Button = script.Parent
local Dind = game.Workspace.Drops.DropIndicator
local Box = game.Workspace.Drops.Box
local down = false
Button.MouseButton1Down:Connect(function()
down = true
local function upDetector()
Button.MouseButton1Up:connect(function()
down = false
coroutine.yield()
end)
end
local upCoroutine = coroutine.create(upDetector)
coroutine.resume(upCoroutine)
while down do
Dind.Position = Vector3.new(Dind.Position.X, Dind.Position.Y, Dind.Position.Z + .1)
wait(.01)
end
end)