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

Teleport player to certain place via GUI?

I'm making a game called Intensity, it's a First and 3rd person shooter. At the moment my GUI when clicked gives the player that gun and the GUI is disabled until they respawn/die. I want it so they spawn on a SpawnLocation of red/blue and teleport to a certain place in the map, I guess this would involve co-ordinates.

So the script wants to be like this..

--Once player selects gun, is cloned from Lightening into backpack --GUI is disabled --Automatically teleport to an area of the map --When die the GUI reappears --Repeats above

1 answer

✓ Accepted answer

To teleport a player, you just have to set his torso's CFrame to the desired coordinates :

script.Parent.MouseButton1Click:connect(function()
--Give gun
game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(Vector3.new(10, 50, 20)) --Make sure to edit those coordinates !
end)

Don't worry about making the script "regen" on death. Since it's a GUI, it will execute each time the player respawns.

4 comments

0

Where would you put this script?

0

It's supposed to be placed inside a button ;)

0

Okay.. at the moment there's a Local script inside the main script. I have the guns inside the text boxes, so when the player clicks on it, the local script clones it and GUI disables.. where would I put the guns in your script?

0

If you want to add a line of code that gives the player a gun, put it at line 2

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