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

How can I have someone click a gui button and have them respawn?

Asked by
HjmanYT -1
6 years ago
Edited 6 years ago
script.Parent.MouseButton1Click:connect(function()
    game.Players.LocalPlayer.CharacterAppearanceId = 149574052
    local Pos = game.Players.LocalPlayer.Character:GetPrimaryPartCFrame()
    game.Players.LocalPlayer:LoadCharacter()
    game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(Pos)
    if game.Players.LocalPlayer.Character:FindFirstChild("ForceField") then
        game.Players.LocalPlayer.Character["ForceField"]:Destroy()
    end
end)

I want them to click a ImageButton and it puts them as the player id I choose then it respawns them, i got it working but only in studio and it said something about the back end server in output and dev console

0
Make sure the script is a LocalScript. thesit123 509 — 6y
1
And can you paste down your script, so I can see? thesit123 509 — 6y
0
Provide the error Goulstem 8144 — 6y
0
Hit `Edit Question` and format your code in Lua Code block Goulstem 8144 — 6y
0
What is the error? hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by
thesit123 509 Moderation Voter
6 years ago

First of all, make sure the script is in a LocalScript. Second of all, if you want to make the player respawn, then why don't you just kill the player? Third of all, you were setting the player PrimaryPartCFrame to where it is currently standing (I think). Fourth of all, I haven't test out the script below.

script.Parent.MouseButton1Click:connect(function()
    game.Players.LocalPlayer.CharacterAppearanceId = 149574052
    game.Players.LocalPlayer:LoadCharacter()

    game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(0, 1, 0) -- Origin of X, Y, Z (Well kinda)

    if game.Players.LocalPlayer.Character:FindFirstChild("ForceField") then
        game.Players.LocalPlayer.Character["ForceField"]:Destroy()
    end
end)

0
You can still make players respawn with :LoadCharacter(). Both ways work. hiimgoodpack 2009 — 6y
0
Oh well... thesit123 509 — 6y
0
Still says the same error HjmanYT -1 — 6y
Ad

Answer this question