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

How can I make the player respawn at the Team Spawn after clicking a Gui Button?

Asked by 5 years ago
01local startergui = game.StarterGui
02 
03script.Parent.MouseButton1Click:Connect(function()
04    script.Parent.Parent.Parent:Destroy()
05    game.StarterGui:WaitForChild("MotherViewPrison",1):Destroy()
06    game.StarterGui:WaitForChild("Prisoners", 1):Destroy()
07    game.Players.LocalPlayer.Team = game.Teams.Police
08    game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
09    game.Workspace.CurrentCamera.CameraType = "Custom"
10end)

Even when the player dies, it doesn't load at the Team Spawn

0
Make sure to turn off CharacterAutoLoading in a server script which can be done by doing game.Players.CharacterAutoLoads = false and to make sure you use Player:LoadCharacter() which can be done through server as well as client. AnnaVonWachstein 7 — 5y

2 answers

Log in to vote
0
Answered by
Rynappel 212 Moderation Voter
5 years ago

Maybe try:

1local plr = sceipt.Parent.Parent.Parent.Parent.Parent.Name
2 
3script.Parent.MouseButton1Click:connect(function()
4game.Players[plr].BrickColor = BrickColor.new("Color") -- Put the color of your team in there
5 
6game.Players.LocalPlayer.Character.Humanoid.Health = 0
Ad
Log in to vote
0
Answered by
FPSVision -14
5 years ago
Edited 5 years ago

One thing that might not work in the script is from lines 5 and 6 I know this isn’t really the answer to your question but it’s one of the answers to fixing your script. If the script is locally I’d suggest you not use StarterGui as that won’t do anything you would rather do.

1game.Players.LocalPlayer.PlayerGui
2 
3-- Instead of game.StarterGui

So switch out lines 5 and 6 for

1-- Line 5
2game.Players.LocalPlayer.PlayerGui:WaitForChild("MotherViewPrison",1):Destroy()
3-- Line 6
4game.Players.LocalPlayer.PlayerGui:WaitForChild("Prisoners", 1):Destroy()
01local player = game.Players.LocalPlayer
02 
03script.Parent.MouseButton1Click:Connect(function()
04    script.Parent.Parent.Parent:Destroy()
05    player.PlayerGui:WaitForChild("MotherViewPrison",1):Destroy()
06    player.PlayerGui:WaitForChild("Prisoners", 1):Destroy()
07 
08 -- The team changing line I removed it because you would need RemoteEvents to change the player’s team or else nobody will see the player being on the police team and the script won’t work so consider learning RemoteEvents/RemoteFunctions
09 
10  -- Link To RemoteEvent And FE Stuff:
12 
13    player:LoadCharacter()  -- Insta Respawns The Player
14end)

Answer this question