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

Teleport player to certain place via GUI?

Asked by
iFlusters 355 Moderation Voter
10 years ago

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

Log in to vote
0
Answered by
Asleum 135
10 years ago

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.

0
Where would you put this script? iFlusters 355 — 10y
0
It's supposed to be placed inside a button ;) Asleum 135 — 10y
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? iFlusters 355 — 10y
0
If you want to add a line of code that gives the player a gun, put it at line 2 Asleum 135 — 10y
Ad

Answer this question