local Players = game:GetService("Players")
local Box1 = script.Parent
local Prize = Box1.Value
local BillboardGui = script.Parent.Parent.BillboardPart.BillboardGui
local Debounce = false
local function tweenCallback(tweenCompleted)
if tweenCompleted then
print("Success!")
else
print("Fail!")
end
end
local function onBoxTouched(hit)
if Debounce then
return
end
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
Debounce = true
local leaderstats = player:WaitForChild("leaderstats")
leaderstats.Money.Value += Prize.Value
leaderstats.Food.Value += 1
BillboardGui.Enabled = true
BillboardGui.Frame.InsideFrame:TweenSize(UDim2.new(0, 200, 1, 0), "Out", "Linear", 5, false, tweenCallback)
task.wait(5)
BillboardGui.Frame.InsideFrame:TweenSize(UDim2.new(0, 10, 1, 0), "Out", "Linear", 5, false, tweenCallback)
task.wait(5)
BillboardGui.Enabled = false
Box1.Transparency = 1
Box1.CanCollide = false
task.wait(10)
Box1.Transparency = 0
Box1.CanCollide = true
Debounce = false
end
end
Box1.Touched:Connect(onBoxTouched)
The “override” parameter was set to true for both tweens (which means they would play over one another), you were also setting the enabled property of the BillboardGui instance to false before the second tween finished playing (I assume this wasn’t intentional).
tysm that works
I tried adding that if the touch ends, it also sets the tween back to normal and ofc visible = false, but it didn’t work. Do you maybe know how this would look?