Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how can i set a limit on my teleport script?

local mouse = script.Parent.Parent:GetMouse()
	
	game:GetService('UserInputService').InputBegan:connect(function(input, gameprossed)
	    if input.KeyCode == Enum.KeyCode.V and not gameprossed then
		
			script.Parent.Parent.Character.Torso.CFrame = CFrame.new(mouse.hit.p)
	end
	end)

how do i set a limit on this teleport script? so it doesnt allow players to teleport to far btw this is a local script

1 comment

0

i looked at this for 2 secs so just an idea: make a variable for the cframe where the mouse hit, lets say "local placeClicked" then do an if statement checking if the distance between the persons cframe and the placeClicked exceeds a distance(the limit), etc... Also add a debounce so players can't spam or whatever.

1 answer

local mouse = script.Parent.Parent:GetMouse()
local debounce = false
local WaitTime = 2 --change this to whatever

game:GetService('UserInputService').InputBegan:connect(function(input,gameprossed)
	if input.KeyCode == Enum.KeyCode.V and not gameprossed then
		if not debounce then
			script.Parent.Parent.Character.Torso.CFrame = CFrame.new(mouse.hit.p)
			debounce = true
			wait(WaitTime)
			debounce = false
		end
	end
end)

2 comments

0

doesnt work

0

was the original script working

This discussion is preserved as it was. New answers, comments, and votes are closed.