I made a team changer script so that when you choose a team, the gui would disable and change your team and respawn you. It works in studio, but not in the game itself. Here is the script:
local player = game.Players.LocalPlayer local teamgui = game.StarterGui.TeamChanger script.Parent.MouseButton1Click:connect(function() teamgui.Enabled = false player.TeamColor = BrickColor.new("Really black") player:LoadCharacter() end)
Is FilteringEnabled on? If so, this code will work in Studio but not on an actual server.
To solve the problem, you'll need to use a RemoteEvent. Here's how I'd structure it:
First off, have a RemoteEvent in ReplicatedStorage. Let's say its name is TeamChanged.
In a script in ServerScriptStorage:
local event = game.ReplicatedStorage:WaitForChild("TeamChanged") event.OnServerEvent:connect(function(player, color) player.TeamColor = color end)
Replace the script you posted with this:
local event = game.ReplicatedStorage:WaitForChild("TeamChanged") -- This is new local player = game.Players.LocalPlayer local teamgui = game.StarterGui.TeamChanger script.Parent.MouseButton1Click:connect(function() teamgui.Enabled = false event:FireServer(BrickColor.new("Really black")) -- This is new player:LoadCharacter() end)
Hopefully this is simple enough; you can read more about RemoteEvents here if you're having trouble understanding.