every time the player holds down the key 1 i want the part to move and when the player stops holding the key i want the part to stop, i tried this but after the first attempt everything stopped working
TestPart = workspace.TestPart
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
local BreakLoop = false
Mouse.KeyDown:Connect(function(key)
print(key)
if key == "1" then
while wait(0.03) do
if BreakLoop == true then
break
end
TestPart.Position = TestPart.Position + Vector3.new(0,0,1)
end
end
end)
Mouse.KeyUp:Connect(function(key)
print(key)--> Shows the key the player is triggered through the output
if key == "1" then
BreakLoop = true
end
end)

1 comment
I tried adding BreakLoop = false in all places I can imagine, but it still won't work.