I currently have a script that is meant to play a tween when a value is set to true, and stop the tween when the value is set to false. The tween gets played when the value gets set to true, but doesn’t stop when the value changes. Here’s my script:
-- Variables above
britvalue:GetPropertyChangedSignal("Value"):Connect(function()
if britvalue.Value == true then
if ameriflag.Decal.Transparency == 0 then
local goal = {Position = bottomvalue}
local ti = TweenInfo.new((bottomvalue.Y - ameriflag.Position.Y)/0.5)
local tween = ts:Create(ameriflag, ti, goal)
tween:Play()
while true do
wait(1)
if script.Parent:WaitForChild("BritishIn").Value == true then
else
tween:Pause()
break
end
if tween.Completed then
for i, v in pairs(ameriflag:GetChildren()) do
if v:IsA("Decal") then
v.Transparency = 1
end
end
break
end
end
end
for i, v in pairs(britflag:GetChildren()) do
if v:IsA("Decal") then
v.Transparency = 0
end
end
local goal = {Position = topvalue}
local ti = TweenInfo.new((topvalue.Y - britflag.Position.Y)/0.5)
local tween = ts:Create(britflag, ti, goal)
tween:Play()
while true do
wait(1)
if script.Parent:WaitForChild("BritishIn").Value == true then
else
tween:Pause()
break
end
if tween.Completed then
game.ReplicatedStorage.FlagA.Value = true
break
end
end
end
end)