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

[Solved] Help make this textcolor lerp back to it's starting value and for it to continue in a loop?

Asked by
awfulszn 394 Moderation Voter
6 years ago
Edited 6 years ago

I have a script, where it checks if I join the game, if it is me, it'll clone a billboard gui above my head, with a textlabel inside. It works, it Shows 'Owner | mosski123' above my head, but I need help with lerping it, I have used lerp to get it from a starting color, to the finish color, in a loop, but I don't know how to make it lerp from the start color, to the finish color and back to the start color in a loop.

Here is my code:

local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")
local start = Vector3.new(255, 85, 255);
local finish = Vector3.new(255, 85, 0);


game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
    if player.Name == "mosski123" then
        local clonedgui = billboardgui:Clone()
        clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
        clonedgui.TextLabel.Text = "Owner | "..player.Name

    while true do       
            for alpha = 0, 1, 0.1 do 
                local offset = start:lerp(finish, alpha);
                clonedgui.TextLabel.TextColor3 = Color3.new(offset.X/255, offset.Y/255, offset.Z/255);
                wait(0.1);
      end
    end
  end)
end)
0
Are you getting any errors? I notice you're missing an 'end' for the for loop at line 14. Put an end after line 17. xPolarium 1388 — 6y
0
Oh, no errors. Though I have fixed it now. awfulszn 394 — 6y

Answer this question