I have a simple change team script. When I go into Play Solo, it works fine. But when I go into a Server with 2 or more people, it doesn't work. I'm pretty sure Load Character cant be used in a Local Script, but is there any way to refresh the character without killing them through a local script?
player = game.Players.LocalPlayer function onClicked() player.TeamColor = BrickColor.new("Bright blue") player:LoadCharacter() end script.Parent.MouseButton1Click:connect(onClicked)
Make the server run the :LoadCharacter() function rather then client, because :LoadCharacter() on a local script will throw an error.
There is not a functional way. If you want to do something about like that use a RemoteEvent.
http://wiki.roblox.com/index.php?title=API:Class/RemoteEvent http://wiki.roblox.com/index.php?title=API:Class/Player/LoadCharacter http://prntscr.com/ajzjag
(This method will work with FE)
[!!!]: IF YOU ENCOUNTER ANY ERRORS MESSAGE ME :[!!!]
-- SERVER --
wait() local event = Instance.new("RemoteEvent", game:GetService("ReplicatedStorage")) event.Name = "RespawnEvent" event.OnServerEvent:connect(function(Player, _) if Player then Player:LoadCharacter() end end)
-- LOCAL --
wait() local event = game:GetService("ReplicatedStorage"):WaitForChild("RespawnEvent") local LocalPlayer = game:GetService("Players").LocalPlayer function onClicked() LocalPlayer.TeamColor = BrickColor.new("Bright blue") event:FireServer("Respawn") end script.Parent.MouseButton1Click:connect(onClicked)
Tell the server to do it
In a script in a RemoteEvent in Workspace:
script.Parent.OnServerEvent:connect((game.Players:GetChildren()[1] or game.Players.PlayerAdded:wait()).LoadCharacter)
In the LocalScript
workspace.LoadCharacter:FireServer()