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

why is my GUI button not teleporting me on click?

Asked by 3 years ago
Edited by Leamir 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

Im Trying to get my gui button to teleport me to my part named Point. It Still ISnt Working And this is what i have got

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.Character.Head.CFrame = CFrame.new(workspace).Point.Position)
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(575.855, -33.5, -273.42))
end)
0
i think its because your putting a vector3 value inside a cframe value and vector3 is i think size VVoretex 146 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

So I generally avoid setting position or anything in the workspace on the client using a local script, but the player position is an exception to filtering enabled, so you could just do this:

script.Parent.MouseButton1Click:Connect(function()
local char=game.Players.LocalPlayer.Character
char.HumanoidRootPart.CFrame=game.Workspace.Point.CFrame*CFrame.new(0,5,0)
end)

It works but is pretty sloppy, just changes the position of the player,sometimes that is all you want, but I doubt that, ppl could also spam the teleport and what not, and later on you might want to say a player needs a certain amount of money to tp or a certain item or a certain level, and putting any of that on the client is too risky, could result in something like, only the player who clicked sees changes, and would let hackers get through easier.

Ad
Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Do this:

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(workspace.Point.Position)
end)

Answer this question