TweenService:Create() failed because instance is null?

I have a for i loop which makes a tween for 3 guis but its saying my setting gui is null? i tried re naming it even re parenting it but it just doesnt work??

code:

local Buttons = {
	PlayButton = {Element = ButtonFrame.PlayButton, Pos = UDim2.new(-0.05, 0,0.08, 0), EndPos = UDim2.new(0.006, 0,0.08, 0)},
	LogButton ={Element = ButtonFrame.UpdateLog, Pos = UDim2.new(-0.05, 0,0.681, 0), EndPos = UDim2.new(0, 0,0.681, 0)},
	SettingsButton = {Elememt = ButtonFrame.Settings, Pos = UDim2.new(-0.05, 0,0.383, 0), EndPos = UDim2.new(0.003, 0,0.383, 0)},

}

local TweenService = game:GetService("TweenService")

local PlayStart = UDim2.new(1.1, 0,0.27, 0)
local PlayStartPos = UDim2.new(-0.047, 0,0.044, 0)

local PlayEnd = UDim2.new(0.996, 0,0.256, 0)
local PlayEndPos = UDim2.new(0.006, 0,0.053, 0)

for i, v in Buttons do
	
	local TweenIn = TweenService:Create(v.Element, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {Size = PlayStart, Position = v.Pos})
	local TweenOut = TweenService:Create(v.Element, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {Size = PlayEnd, Position = v.EndPos})
	
	v.Element.MouseEnter:Connect(function()
		TweenIn:Play()
		
		v.Element.MouseLeave:Connect(function()
			TweenOut:Play()
		end)
	end)
	
end

image

image

My guess is that when you create a tween, it REQUIRES you to have all your values in a table.
This is what you’re doing.

 TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)

What you should be doing

local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)

local tweenIn = (v.Element, tweenInfo, whatever goes here)
local tweenOut = (you know what goes here)

Edit: I just realized you are FORCED to do what I posted above.
To make a tween, you are required to make a variable that stores the tweenInfo with the function TweenInfo.new, if you don’t do this it errors you!

Edit 2: OOPS I didn’t see that you already did TweenInfo.new, but you should consider storing it in a variable however, maybe thatll make it easier on the script.

Edit 3: You should consider doing what I suggested on Edit 2 with the 3rd paramater of TweenService:Create() I don’t know if it will help but hey its worth a shot

1 Like

Found out the problem was this typo:

crazy.

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