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

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago
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
Ad
Log in to vote
-1
Answered by 6 years ago
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

Answer this question