So, I have this script that is supposed to show a gui when a value changes. But when I change the value, the gui doesn’t appear. I have tried using .Changed
and that worked, well mostly. It kinda just only showed the gui when the value changes to a different one from the previous. How do I fix this?
script.Parent.Parent.CurrentUnit:GetAttributeChangedSignal("Value"):Connect(function()
local value = script.Parent.Parent.CurrentUnit:GetAttribute("Value")
script.Parent.Parent.Tower.Text = value
script.Parent.Parent.Tier.Text = checkTier(value)
script.Parent.Parent.Size = UDim2.new(0.01, 0, 0.01, 0)
script.Parent.Parent.Visible = true
script.Parent.Parent:TweenSize(UDim2.new(0.256, 0, 0.581, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.5, true)
for i,tower in ipairs(workspace.ViewportFrames.SummonedUI:GetChildren()) do
--print(script.Parent.Parent.CurrentUnit.Value, tower.Name)
if script.Parent.Parent.CurrentUnit.Value == tower.Name or script.Parent.Parent.CurrentUnit.Value == tower.Config.OriginalTower.Value then
local clone = tower:Clone()
clone.Parent = script.Parent.WorldModel
end
end
for i = 1,100 do
wait(3 / 100)
end
if script.Parent.Parent.Visible then
script.Parent.Parent:TweenSize(UDim2.new(0.01, 0, 0.01, 0), Enum.EasingDirection.In, Enum.EasingStyle.Back, 0.5, false)
wait(0.5)
script.Parent.Parent.Visible = false
end
end)