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)
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.)