Script won't work even after enabling bool?

So, If the pet’s rainbow value is true, then i want the game to clone a script to the pet’s highlight to show that it’s rainbow. However, when cloning this script to the pet and enabling the bool in it, it does not function. Why does this happen? Here is the code:

while script.Nable.Value do -- bool that the game enables with the clone

wait(0.1) 
game:GetService('TweenService'):Create(
    script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
{FillColor = Color3.fromRGB(255, 0, 0)}):Play() 
wait(1.1)

game:GetService('TweenService'):Create(
    script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
{FillColor = Color3.fromRGB(255, 155, 0)}):Play() 
wait(1.1)

game:GetService('TweenService'):Create(
    script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
{FillColor = Color3.fromRGB(255, 255, 0)}):Play() 
wait(1.1)

game:GetService('TweenService'):Create(
    script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
{FillColor = Color3.fromRGB(0, 255, 0)}):Play() 
wait(1.1)

game:GetService('TweenService'):Create(
    script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
{FillColor = Color3.fromRGB(0, 255, 255)}):Play() 
wait(1.1)

game:GetService('TweenService'):Create(
    script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
{FillColor = Color3.fromRGB(0, 155, 255)}):Play() 
wait(1.1)

game:GetService('TweenService'):Create(
    script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
{FillColor = Color3.fromRGB(255, 0, 255)}):Play() 
wait(1.1)

game:GetService('TweenService'):Create(
    script.Parent,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
{FillColor = Color3.fromRGB(255, 0, 155)}):Play() 
wait(1.1)
end 

Code that activates it:

function stylepet(pet, model)
	
	if pet.Shiny.Value == true then
		model.Highlight.FillColor = Color3.fromRGB(255, 255, 255)
		model.Head.Middle.Shiny.Enabled = true
		model.Highlight.Enabled = true
	end
	
	if pet.Gold.Value == true then
		for _, Part in pairs(model:GetDescendants()) do
			if Part:IsA("BasePart") then
				Part.Material = Enum.Material.Foil
			end
		end
		model.Highlight.FillColor = Color3.fromRGB(255, 191, 0)
		model.Highlight.Enabled = true
	end
	
	if pet.Rainbow.Value == true then
		model.Highlight.FillColor = Color3.fromRGB(255,255,255)
		local rb = script.RB:Clone()
		rb.Parent = model.Highlight
		rb.Nable.Value = true
		model.Highlight.Enabled = true
	end
	
end

Any help would be appreciated, I seriously have no idea what to do!

4 Likes

u probably have to wrap it in the true do loop as the condition doesnt updates

while true do
    if script.Nable.Value then
       --all ur code here
3 Likes

I don’t think the rainbow script is very good, try using this one instead

If you still want to use your code tho i recommend using Tween.Completed:Wait() and make a variable for the TweenService instead of calling GetService over an over again

AND i dont think you need to make the tween over and over again, just create them once outside the while loop

1 Like

If the cloned script runs before the bool==true then it won’t run at all since it just skips the while loop and ends the script. A safe option would be

while true do
    if bool then
        --code
    end
end

I tried putting the bool in the while loop, but it’s still not showing rainbow effects on the highlight. I was using the script that Schaap linked.

(and i did change brick to script.parent)

Try adding a print before the if statement, to see if the while loop even runs
And what type are the scripts, are they a local script or just a normal script?