Hi, i’ve been trying to make my gui color changing script break a loop, and the loop is used to change the colors, looping through colors, like a rainbow sort of, and the problem i’m having is i don’t know how i should break the loop.
Script
The script is in ServerScriptService.
local ReplicatedStorage = game.ReplicatedStorage local ColorChangeBlack = ReplicatedStorage:WaitForChild("ColorChangeBlack") local ColorChangeRed = ReplicatedStorage:WaitForChild("ColorChangeRed") local ColorChangePink = ReplicatedStorage:WaitForChild("ColorChangePink") local ColorChangePurple = ReplicatedStorage:WaitForChild("ColorChangePurple") local ColorChangeBlue = ReplicatedStorage:WaitForChild("ColorChangeBlue") local ColorChangeGreen = ReplicatedStorage:WaitForChild("ColorChangeGreen") local ColorChangeYellow = ReplicatedStorage:WaitForChild("ColorChangeYellow") local ColorChangeOrange = ReplicatedStorage:WaitForChild("ColorChangeOrange") local ColorChangeWhite = ReplicatedStorage:WaitForChild("ColorChangeWhite") local ColorChangeTeal = ReplicatedStorage:WaitForChild("ColorChangeTeal") local ColorChangeToothpaste = ReplicatedStorage:WaitForChild("ColorChangeToothpaste") local ColorChangeRainbow = ReplicatedStorage:WaitForChild("ColorChangeRainbow") ColorChangeBlack.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.new(0,0,0) -- This line uses the the player object returned by the OnServerEvent end) ColorChangeRed.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.new(255,0,0) -- This line uses the the player object returned by the OnServerEvent end) ColorChangePink.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.new(255, 0, 191) -- This line uses the the player object returned by the OnServerEvent end) ColorChangePurple.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.fromRGB(123, 0, 123) -- This line uses the the player object returned by the OnServerEvent end) ColorChangeBlue.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.new(0,0,255) -- This line uses the the player object returned by the OnServerEvent end) ColorChangeGreen.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.new(0,255,0) -- This line uses the the player object returned by the OnServerEvent end) ColorChangeYellow.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.new(255,255,0) -- This line uses the the player object returned by the OnServerEvent end) ColorChangeOrange.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.fromRGB(213, 115, 61) -- This line uses the the player object returned by the OnServerEvent end) ColorChangeWhite.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.new(255,255,255) -- This line uses the the player object returned by the OnServerEvent end) ColorChangeTeal.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.fromRGB(0, 143, 156) -- This line uses the the player object returned by the OnServerEvent end) ColorChangeToothpaste.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.fromRGB(0,255,255) -- This line uses the the player object returned by the OnServerEvent end) ColorChangeRainbow.OnServerEvent:Connect(function(player,activated) -- The first parameter is always the player object while true do for a = 1,360,1 do wait(.05) player.Character.Head.TitleGUI.TitleLabel.TextColor3 = Color3.fromHSV(a/360,1,1) -- Changes colors end end -- This line uses the the player object returned by the OnServerEvent end)
Details
- The point of the script is to have RemoteEvents which are made for each color, which are fired on server from the client localScript when activated, and using them to change colors of a gui.
What would be a good way to do this?
I thought about breaking the loop when another RemoteEvent was fired, but i couldn’t find any functions for it, and i can’t think of many other ways, so i don’t know how i should do this.
Thanks, all help is appreciated!