✓ Accepted answer
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")
local player = game.Players.LocalPlayer
local teamgui = game.StarterGui.TeamChanger
script.Parent.MouseButton1Click:connect(function()
teamgui.Enabled = false
event:FireServer(BrickColor.new("Really black"))
player:LoadCharacter()
end)
Hopefully this is simple enough; you can read more about RemoteEvents here if you're having trouble understanding.
1 comment
The client's UI is not located in StarterGui