Basically this is just a test teleport script and I am trying to figure out how to loop it while the V key is held down. When you press V it teleports you to two different locations as you can see below. Would it be possible to keep teleporting back and forth (loop) and stop when you let go of the V key? I can't seem to figure this out. Your help is very much appreciated!
local client = game:GetService("Players").LocalPlayer game:GetService("UserInputService").InputBegan:Connect(function(input, gpe) if gpe then return end if input.KeyCode == Enum.KeyCode.V then client.Character:SetPrimaryPartCFrame(CFrame.new(275,3.94,347.568)) wait(0.1) client.Character:SetPrimaryPartCFrame(CFrame.new(275,5.94,347.568)) end end)
here u go
local pressed = false local client = game:GetService("Players").LocalPlayer game:GetService("UserInputService").InputBegan:connect(function(input, gpe) if gpe then return end if input.KeyCode == Enum.KeyCode.V then pressed = true while pressed == true do client.Character:SetPrimaryPartCFrame(CFrame.new(275,3.94,347.568)) wait(0.1) client.Character:SetPrimaryPartCFrame(CFrame.new(275,5.94,347.568)) wait(0.1) end end end) game:GetService("UserInputService").InputEnded:connect(function(input, gpe) if gpe then return end if input.KeyCode == Enum.KeyCode.V then pressed = false end end)