Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Function for teleport script won't work. Help?

Asked by 5 years ago

So i'm trying to make a tool where when you activate the tool, it teleports you to where your mouse's cursor is. It's a local script.

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local plrn = plr.Name
local plrchr = game.Workspace:WaitForChild(plr.Name, 10000)

tping = false

script.Parent.Activated:Connect(function()
    mouse.Button1Down:Connect(function()
        if tping == false then
        wait(0.1)
        tping = true
        plrchr.HumanoidRootPart.CFrame = mouse.Hit
        wait(0.25)
        tping = false
        end
    end)
end)

Can someone help me with this?

1 answer

Log in to vote
0
Answered by
xEmmalyx 285 Moderation Voter
5 years ago

The script works fine for me when I inserted it into a LocalScript inside of a tool. Make sure the tool has "RequiresHandle" set to false

Ad

Answer this question