i make a team selection gui in StarterGui. i also added a local script to make the selection screen gone and added a humanoid in player character. it did work fine until i tested it on server with 2 players. the gui did disappeared and both worked fine for 2 players but the bool value that i place on the workspace didnt change its value.
--startgame script.Parent.choose.Defend.Activated:connect(function() local defend = Instance.new("Humanoid") defend.Name = "Defend" defend.Parent = game.Players.LocalPlayer.Character script.Parent.choose.Enabled = false game.Workspace.defend.Value = true end) script.Parent.choose.Prosecutor.Activated:connect(function() local prosecutor = Instance.new("Humanoid") prosecutor.Name = "Prosecutor" prosecutor.Parent = game.Players.LocalPlayer.Character script.Parent.choose.Enabled = false game.Workspace.prosecutor.Value = true end) --ready
You need to fire a RemoteEvent
to change a value on the server(for everyone). Local scripts only interact with the client.
An example of a RemoteEvent:
ServerScript
local replicated = game:GetService("ReplicatedFirst") local exampleevent = Instance.new("RemoteEvent") exampleevent.Parent = replicated exampleevent.Name = "Example" function OnFired(plr) plr.leaderstats.Value = plr.leaderstats.Value + 1 end exampleevent.OnServerEvent:Connect(OnFired)
LocalScript:
local replicated = game:GetService("ReplicatedFirst") local examplevent = replicated:WaitForChild("Example") local player = game.Players.LocalPlayers script.Parent.MouseButton1Click:Connect(function() exampleevent:FireServer(player) end)
If you need more help then click here