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

LoadCharacter can only be called by the backend server?

Switch Team, how to fix and why it not works?

Error: LoadCharacter can only be called by the backend server

LocalScript:

script.Parent.MouseButton1Click:connect(function()
	game.Players.LocalPlayer.TeamColor = BrickColor.new("Light stone grey")
	game.Players.LocalPlayer:LoadCharacter()
	print(game.Players.LocalPlayer.Name.." has changed team to "..script.Parent.Name.." team!")
end)

1 answer

Well, if I recall correctly, LoadCharacter can only be called on the Server. To use LoadCharacter in this sense, you'd have to use A RemoteEvent. Here's an example:

Hierarchy: ReplicatedStorage.LoadChar[RemoteEvent] ServerScriptService.RemoteHandler[Script]

LocalScript:

script.Parent.MouseButton1Click:connect(function()
    game.Players.LocalPlayer.TeamColor = BrickColor.new("Light stone grey")
    game.Players.LocalPlayer:LoadCharacter() --game:GetService("ReplicatedStorage")
    print(game.Players.LocalPlayer.Name.." has changed team to "..script.Parent.Name.." team!")
end)

ServerScript:

game:GetService("ReplicatedStorage").LoadChar.OnServerEvent:connect(function(player)
	player:LoadCharacter()
end)

(Please Note: I wrote this in the ScriptingHelper's question editor, so pardon any mistakes.)

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