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

Can anyone fix this script? (Involves LoadCharacter)

So I want the player to be able to click a ScreenGui's TextButton and respawn the player without actually killing them

local name = game.Players.LocalPlayer --Get their name.

TextButton.MouseButton1Click:connect(function()
if game.Players:FindFirstChild(name) then --Is there a player with that name?
    game.Players:FindFirstChild(name):LoadCharacter()
end
end)

This is confusing me, i've been looking at sources the past literal 3 hours watching the RT podcast on my other monitor, and I cannot figure this out, I've looked all around and altered this and many others scripts.

This is how it's ordered if it helps | StarterGui ScreenGui TextButton LocalScript

3 answers

✓ Accepted answer

Try:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
    player:LoadCharacter()
end)

Simple as that.

1 comment

1

You can't use LoadCharacter in a local script

Put this in a LocalScript and you're good

local Player=game.Players.LocalPlayer
TextButton.MouseButton1Click:connect(function()
	Player:LoadCharacter()
end)

2 comments

0

Thanks for the reply but it didn't work.

0

Read cntkillme's comment

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