I am trying to change the colour of the current player's username to cycle through different colours when I press a button. It works when there is one player in the game but not when another joins. The boolean value keeps getting automatically set to false. What am I doing wrong?
Local script in StarterGui.ScreenGui.TextButton
script.Parent.MouseButton1Click:Connect(function() game.ReplicatedStorage.UpdateBoolean:FireServer() end)
Server script in ServerStorage.OverheadGui.Username Rainbow boolean value in ServerStorage.OverheadGui.Username
game.ReplicatedStorage.UpdateBoolean.OnServerEvent:Connect(function(player) local rainbow = game.Workspace:WaitForChild(player.Name).Head.OverheadGui.Username.Rainbow rainbow.Value = not rainbow.Value while rainbow.Value == true do for a = 1,150,1 do wait(0.1) game.Workspace:WaitForChild(player.Name).Head.OverheadGui.Username.TextColor3 = Color3.fromHSV(a/150,1,1) if rainbow.Value == false then wait(.3) break end end end game.Workspace:WaitForChild(player.Name).Head.OverheadGui.Username.TextColor3 = Color3.fromHSV(0, 0, 1) end)
I recreated what you made and was able to fix the issue by moving the server script to serverscriptservice