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

How exactly do you teleport someone on Roblox Studio?

I'm making a script for a tool that allows a player to Teleport to a location that they click to. However, it only breaks the game and dislodges the camera from the body. I need a fix that works with both R6 and R15

Code: mouse.Button1Down:connect(function(key) if mouse.Target then character.HumanoidRootPart.Position = Vector3.new(mouse.Hit.x, mouse.Hit.y + 5, mouse.Hit.z) end end)

1 answer

✓ Accepted answer

Here, This will be put into a local script in a tool

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local active = false
mouse.Button1Down:Connect(function()
	if active == true then
	local hrp = plr.Character.HumanoidRootPart
	hrp.CFrame = mouse.Hit
		end
end)


script.Parent.Equipped:Connect(function()
	active = true
end)
script.Parent.Unequipped:Connect(function()
	active = false
end)

Be sure to accept this answer if it works for you :)

1 comment

0

Please post an explanation to explain. For more information see: https://github.com/WillSullivan/idownvotedbecause/issues/105

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