Seemingly simple code isn't working

so I want to make a tween for a frame to shrink down on the x axis in front of the button pressed but it’s scaling to 0 for no apparent reason.

script:

local player = game.Players.LocalPlayer
local character = player.Character
local hum = character:WaitForChild("Humanoid")
local gui = script.Parent.Parent
local frame = gui.Frame
local Button = gui.DashButton
local UIS = game:GetService("UserInputService")
local CoolDown = 5
local CanDash = true
local TS = game:GetService("TweenService")

local info = TweenInfo.new(
	CoolDown,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In,
	0,
	false,
	0)

local goals = {Size = UDim2.new({0, 76},{0, 10}), Position = UDim2.new({0.785, 0},{0.738, 0})}

local TimeTween = TS:Create(frame,info,goals)*emphasized text*


Button.Activated:Connect(function(hit)
	if CanDash == true then
		game.ReplicatedStorage.RemoteEvents.DashEvent:FireServer(hum)
		TimeTween:Play()
		CanDash = false
		wait(CoolDown)
		CanDash = true
	end
end)

I tried:

	frame:TweenSize(
		UDim2.new({0,76},{0, 1}),
		Enum.EasingDirection.In,
		Enum.EasingStyle.Linear,
		CoolDown,
		false)

but switched to the other tweenservice because I’m more comfortable with it.

Also I only just learned how to do UDim2 stuff so sorry for maybe being stupid
thanks!

I doubt it knowing the tween played, but do you get any errors? Please show me if you do.

As well as what is the anchor point of that frame? That could be causing the issue (probably not, but roblox is weird)

I would also recommend removing the curly brackets inside of the UDim2s. Unimportant, but just a recommendation.

1 Like

You have to parent it to a frame to handle size changes, unless I am wrong

2 Likes

no errors.
But anchor points might be the problem because I don’t know what they are

From what it looks like, I’m going to guess the anchor point is 0, 0, however I could be wrong.

Anyway, if the frame is not parented to the ImageLabel like @hasoco said, then do that (only if you want the frame to be constricted to the boundaries of the ImageLabel)

1 Like

It works a lot better now but it still scales itself to 0

also I edited the script a tiny bit:

local player = game.Players.LocalPlayer
local character = player.Character
local hum = character:WaitForChild("Humanoid")
local gui = script.Parent.Parent
local frame = gui.DashButton.Frame
local Button = gui.DashButton
local UIS = game:GetService("UserInputService")
local CoolDown = 5
local CanDash = true
local TS = game:GetService("TweenService")

local info = TweenInfo.new(
	CoolDown,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In,
	0,
	false,
	0)

local goals = {Size = UDim2.fromOffset({0, 76},{0, 10}), Position = UDim2.new({0, 0},{0.921, 0})}

local TimeTween = TS:Create(frame,info,goals)


	Button.Activated:Connect(function(hit)
	if CanDash == true then
		frame.Size = UDim2.fromOffset({0, 76},{0, 75})
		game.ReplicatedStorage.RemoteEvents.DashEvent:FireServer(hum)
		TimeTween:Play()
		CanDash = false
		wait(CoolDown)
		CanDash = true
	end
	end)

This part looks suspicious, I think UDim2.fromOffset only picks the first value from a table, so just replace it with 76,10

2 Likes

That would be the issue.

Character limit

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.