Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I need help with this script?

When you hover the background gets longer when you leave it gets smaller this is the error.

13:14:04.680 - Players.Player.PlayerGui.Gui.Frame.Frame.TextButton.Script:4: attempt to compare > > two userdata values 13:14:04.681 - Stack Begin 13:14:04.683 - Script 'Players.Player.PlayerGui.Gui.Frame.Frame.TextButton.Script', Line 4 13:14:04.684 - Stack End

And this is the code.

local background  = script.Parent.Parent.Background

function enter()
	while background.Size < UDim2.new(0,250,0,50) do
		wait(.5)
		local bgd = background.Size + UDim2.new(0,10,0,0)
	end
end

function leave()
	while background.Size > UDim2.new(0,0,0,50) do
		wait(.5)
		local bgs = background.Size - UDim2.new(0,10,0,0)
		background.Size = bgs
	end
end
script.Parent.MouseEnter:connect(enter)
script.Parent.MouseLeave(leave)

Thanks for the help.

2 comments

0

You cannot compare a GUI size and a UDim2 value.

0

Look at me silly mistake mouseleave

1 answer

As obcdino said, you cannot compare a GUI size and a UDim2 value.'

You can simplify your code with a TweenSize. http://wiki.roblox.com/index.php?title=API:Class/GuiObject/TweenSize

Take out:

while background.Size > UDim2.new(0,0,0,50) do

and

local bgs = background.Size - UDim2.new(0,10,0,0)

and do Code:

background:TweenSize(UDim2.new(0,10,0,0),'Out','Quad',.5,true)

Just replace the UDim2 values with the new size of the GUI, and set the number to the number of seconds for it to take to tween.

This discussion is preserved as it was. New answers, comments, and votes are closed.