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

Script that is supposed to make a rainbow effect only works for a few seconds why ?

So i have this script that should give me the name tag of owner which it does but the rainbow effect only works for like 4 seconds and then it stops. Any idea why ?

local billboardgui = game:GetService("ReplicatedStorage"):WaitForChild("BillboardGui")
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
	if player.Name == "1Messi3903" then -- change "alvinbloxx" to "YOUR NAME"
		local clonedgui = billboardgui:Clone()
		clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
		clonedgui.TextLabel.Text = "Owner"
		for i = 0,1,0.01 do
		clonedgui.TextLabel.TextColor3 = Color3.fromHSV(i,1,1)
		wait(.1)
		end
	end
	if player:IsInGroup(0) then
		local clonedgui = billboardgui:Clone()
		clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
		clonedgui.TextLabel.Text = "Owner"
		clonedgui.TextLabel.TextColor3 = Color3.fromRGB(231,206,12)
	end
	end)
end)

2 answers

for i = 0,1,0.01 do -- this loop does not go on forever, it should last 10 seconds
	clonedgui.TextLabel.TextColor3 = Color3.fromHSV(i,1,1)
	wait(.1)
end

you could fix it by simply doing

while true do
	for i = 0,1,0.01 do
		clonedgui.TextLabel.TextColor3 = Color3.fromHSV(i,1,1)
		wait(.1)
	end
end

or use :lerp()

	while wait(.1) do
		math.randomseed(os.time())
		local r = math.random(1,255)
		local b = math.random(1,255)
		local g = math.random(1,255)
		clonedgui.TextLabel.TextColor3 = clonedgui.TextLabel.TextColor3:lerp(Color3.fromRGB(r, g, b), .05)
	end
local billboardgui = game:GetService("ReplicatedStorage"):WaitForChild("BillboardGui")
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
    if player.Name == "1Messi3903" then -- change "alvinbloxx" to "YOUR NAME"
        local clonedgui = billboardgui:Clone()
        clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
        clonedgui.TextLabel.Text = "Owner"
      while true do
        for i = 0,1,0.01 do
        clonedgui.TextLabel.TextColor3 = Color3.fromHSV(i,1,1)
        wait(.1)
        end
    end
    end
    if player:IsInGroup(0) then
        local clonedgui = billboardgui:Clone()
        clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
        clonedgui.TextLabel.Text = "Owner"
        clonedgui.TextLabel.TextColor3 = Color3.fromRGB(231,206,12)
    end
    end)
end)

try this

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