Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Change colour of username on button press event?

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)

1 answer

I recreated what you made and was able to fix the issue by moving the server script to serverscriptservice

1 comment

0

Brilliant, thank you, that worked.

This discussion is preserved as it was. New answers, comments, and votes are closed.