Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Change colour of username on button press event?

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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

0
Brilliant, thank you, that worked. driver_888 0 — 2y
Ad

Answer this question