Why does this shrink my gui into infinity?

Im making an elemental game, and i am doing polishing to the gui buttons by using tweenservice to largen the button when clicked. But instead of getting larger, it shrinks into infinity. No matter what i put as size this happens. Here is the code (localscript)

local uis = game:GetService("UserInputService")
local ts = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local btn = game.StarterGui.moves.e

local goal = {}
goal.Size = UDim2.new({0,5, 0},{0.5, 0})
local tweeninfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)

Any ideas as to why this is happening? Thanks!

3 Likes

theres a typo

goal.Size = UDim2.new({0,5, 0},{0.5, 0})

should be

goal.Size = UDim2.new({0.5, 0},{0.5, 0})

and I would use Udim2.fromScale

Change that

to this:

goal.Size = UDim2.new(0.5, 0, 0.5, 0)

since you’ve miss-formatted the creation of the UDim2.

3 Likes

Umm, I believe one can only use the tween service if the object you are tweening is a descendant of workspace.

That’s not right.
Nowhere in the TweenService documentation entry states that exception, plus, TweenService can be, indeed, used outside of the WorkSpace (take this case for instance, all the times Tweens have been used in GUIs).

1 Like

Ok, maybe, but I’ve seen lots of people that have gotten this error and even got it myself at one point while trying to tween a GUI. If there’s something I’m missing, then please let me know! :smile:

Oh, I see, interesting.

Since the Workspace is being referred as ‘workspace’ in that error (like, not capitalized), I don’t think it’s referring to the proper Workspace Service (game.Workspace/game:GetService("Workspace")), rather it must be referring to the script’s workspace (environment) or something like that.
After some investigation, this guy solved their instance of the issue by not saving their GUI instance to a variable and using that variable, but directly referencing it through an ancestor of it, so most likely it’s the script’s environment:

Hope that helps, but yeah, I agree it’s a weird error (and message), haha.

Ok! I think I get it now thanks!

1 Like

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