i want to make brick named "cam" move when im still pressing key, not only when im pressed it but i getting error when im using InputEnded, what can i do?
UIS.InputBegan:Connect(function(key, gp) if key.KeyCode == HK then repeat wait(.1) move(key) until UIS.InputEnded() elseif key.KeyCode == HK2 then repeat wait(.1) move(key) until UIS.InputEnded() end end) function move(key) print(camera.Position.Y) if key.KeyCode == HK then if check() == true then local newpos = camera.Position.Y + 1 camera.Position = Vector3.new(camera.Position.X,newpos, camera.Position.Z) end end if key.KeyCode == HK2 then if check2() == true then local newpos = camera.Position.Y - 1 camera.Position = Vector3.new(camera.Position.X,newpos, camera.Position.Z) end end end function check() if camera.Position.Y < 221 then return true elseif camera.Position.Y == 221 then return end end function check2() if camera.CFrame.Y > 34 then return true elseif camera.Position.Y == 34 then return end end
Change your repeat loops. InputEnded is a signal, not a function. You're calling it like a function, which will error. However, we can use UIS:IsKeyDown(HK) to determine if the ke is being held or not. Since we're checking for it to be ended, we place a "not" in front of it.
repeat wait(.1) move(key) until not UIS:IsKeyDown(HK)