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

Cant reload player's character?

function ReloadChar()
	script.Parent.Parent.Parent.Parent:LoadCharacter()
end

script.Parent.MouseButton1Down:Connect(ReloadChar)

when i click the gui it won't do anything

the error is

LoadCharacter can only be called by the backend server

cant understand why someone help

3 comments

0

You may have to make it fire an event that connects to a server script, and then it loads the character from there.

0

Don't forget to accept my answer if it helps out.

0

ok got it thanks

1 answer

✓ Accepted answer

Error explains itself. You're calling it from a local script. You will need a remote event. Also, in the future, do not use script.Parent.Parent.Parent.Parent to get the player. Use LocalPlayer to get the player from a local script.

-- # remember to define `remoteEvent`
remoteEvent.OnServerEvent:Connect(function(client)
    client:LoadCharacter()
end)

Here i'm just listening on the server side for OnServerEvent to be fired. When it is, the character of the player who fired the remote gets reloaded.

And from the client you would call remoteEvent:FireServer() to fire the server event.

local function ReloadChar() -- # localise! 
    remoteEvent:FireServer() -- # remember to define `remoteEvent`
end

script.Parent.Activated:Connect(ReloadChar)
-- # Activated is the recommended way of getting GUI click input.

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