Frame isn't tweening properly

Hey,

I just copied a tween from another game, but somehow its not working right.

This is how it should look:

This is how it looks (look at the end of the animation)

image

How I said, i just copied the model so all frames are the same size.

Script:

local Box1 = script.Parent
local BillboardGui = script.Parent.Parent.BillboardPart.BillboardGui

Box1.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local leaderstats = player:WaitForChild("leaderstats")
		local Amount = script.Parent.Value.Value

		BillboardGui.Enabled = true
		BillboardGui.Frame.InsideFrame:TweenSize(UDim2.new(0, 200,1, 0), "Out", "Linear", 5, true)
		wait(5)
		BillboardGui.Enabled = false
		BillboardGui.Frame.InsideFrame:TweenSize(UDim2.new(0, 10,1, 0), "Out", "Linear", 5, true)
		Box1.Transparency = 1
		Box1.CanCollide = false
		leaderstats.Money.Value = leaderstats.Money.Value +(Amount)
		leaderstats.Food.Value = leaderstats.Food.Value +(1)
		wait(10)
		Box1.Transparency = 0
		Box1.CanCollide = true
	end
end)

Is the video laggy or is it just really me. Also, can you send the script? So we can help you in your script?

1 Like

Send your script, and you should be tweening it until Scale.X == 1 to fill the whole frame.

2 Likes

Added the script. But in the other game it works, so this cant be the problem

Idk, it might lag a bit but you should see everything.

Did you find a problem? I added a debounce, but its still not working.

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).

1 Like

Hey,

tysm that works :slight_smile:
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?