My GUI doesnt flash or do anything!

So I made a GUI object and have a object in it flash, however only when it is equipped to prevent lag of course. And the script gives no errors and no response either. Any help?

local TweenService = game:GetService("TweenService")

local CH_Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)

local CH_Properties = {
	Size = UDim2.new(0, 400,0, 200),
	ImageTransparency = 1,
	ImageColor3 = Color3.fromRGB(117, 117, 117)
}

local GUI = script.Parent:WaitForChild("GunClient"):WaitForChild("GunGUI")

ShouldFlash = false

while true do
	if ShouldFlash == true then
		local Clone = GUI.Frame.BG:Clone()
		Clone.Parent = script.Parent.Parent
		local Tween = TweenService:Create(Clone, CH_Info, CH_Properties)
		Tween:Play()
		Tween.Completed:Wait()
		Clone:Destroy()
	end
	task.wait(1.25)
end

script.Parent.Equipped:Connect(function()
	ShouldFlash = true
end)

script.Parent.Unequipped:Connect(function()
	ShouldFlash = false
end)

Your while true prevents the script from connecting to Equipped and whatnot. If you move the while true to the bottom of the script it should work

I’ve now done this and the script still does not work.

local TweenService = game:GetService("TweenService")

local CH_Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)

local CH_Properties = {
	Size = UDim2.new(0, 400,0, 200),
	ImageTransparency = 1,
	ImageColor3 = Color3.fromRGB(117, 117, 117)
}

local GUI = script.Parent:WaitForChild("GunClient"):WaitForChild("GunGUI")

ShouldFlash = false

script.Parent.Equipped:Connect(function()
	ShouldFlash = true
end)

script.Parent.Unequipped:Connect(function()
	ShouldFlash = false
end)

while true do
	if ShouldFlash == true then
		local Clone = GUI.Frame.BG:Clone()
		Clone.Parent = script.Parent.Parent
		local Tween = TweenService:Create(Clone, CH_Info, CH_Properties)
		Tween:Play()
		Tween.Completed:Wait()
		Clone:Destroy()
	end
	task.wait(1.25)
end

Why are you cloning it? Why not do it straight to the GUI.Frame.BG?
It could be because they are overlapping, and that it is actually flashing, but one of them is on top / under.

Well, i’m a bit unsure what you mean by doing it straight to it, and also. Wouldn’t it be visible if the tween makes it bigger?

I don’t know what your UI looks like, so I’m not very sure.
Also, why not just tween the actual thing instead of cloning it and then tweening it?

It’s meant to have a sort of pulse effect. It’s meant to make the red background be tweened. Here’s what it looks like:

image

I would of done a script that does this permanently but it could create lag if the tool is not equipped.

so why not just tween the background then…?

It’s meant to be cloned to create the pulse effect, heres what I mean.

(you can just about see the effect on the borders of it, its hard to explain the effect)

try putting the while true do in a coroutine