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

I'm teleporting a player when the player presses a guibutton, why does this script not work?

Asked by 4 years ago
teleportposition = CFrame.new(-17.93, 0.5, 360.89)

script.Parent.MouseButton1Click:Connect(function(clicked)
    if clicked.Character:FindFirstChild("Humanoid") then
    clicked.Character.HumanoidRootPart.CFrame =  teleportposition
    end
end)

1 answer

Log in to vote
0
Answered by
G2001H 75
4 years ago

Use LocalScript

script.Parent.MouseButton1Click:Connect(function()
    local player = game.Players.LocalPlayer
    if player.Character:FindFirstChild("Humanoid") then
    player.Character.HumanoidRootPart.CFrame =  CFrame.new(-17.93, 0.5, 360.89)
    end
end)
Ad

Answer this question