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

GUI Error. Anyone know what this is?

Hi! I'm making a GUI and i was tweening the size of a TextButton. When doing this, I encountered an error. The error was this:

Unable to cast double to token Script 'Players.KordGamer.PlayerGUI.ScreenGUI.Frame.CreditsButton.S', Line 2.

and Unable to cast double to token Script 'Players.KordGamer.PlayerGUI.ScreenGUI.Frame.CreditsButton.S', Line 6.

Here is the code :

function Hover()
	script.Parent:TweenSize(0.05, 200, 0.05, 50)
end

function StopHovering()
	script.Parent:TweenSize(0, 200, 0, 50)
end

function Click()
	--TODO: Make click function
end

script.Parent.MouseEnter:connect(Hover)
script.Parent.MouseLeave:connect(StopHovering)

Any help is appreciated. Thank you!

2 answers

✓ Accepted answer

The first argument of the TweenSize function is a UDim2 value. You're a using a number so the script will error. To fix this, you need to wrap those numbers around UDim2.new() inside the parenthesis. You will also need some extra arguments such as EasingDirection, EasingStyle and Time in order for the TweenSize function to work.

Overall, you script should look something like this:

function Hover()
	script.Parent:TweenSize(UDim2.new(0.05, 200, 0.05, 50),"Out","Quad",1,true) --Tweens the size in one second in the EasingDirection of Out and with the EasingStyle of Quad. You need the true at the end so you can do the StopHovering tween if it's called mid way through.
end

function StopHovering()
	script.Parent:TweenSize(UDim2.new(0, 200, 0, 50),"Out","Quad",1) --Tweens the size in one second in the EasingDirection of Out and with the EasingStyle of Quad. You need the true at the end so you can do the Hovering tween if it's called mid way through.
end

function Click()
    --TODO: Make click function
end

script.Parent.MouseEnter:connect(Hover)
script.Parent.MouseLeave:connect(StopHovering)

I hope my answer helped you. If it did, be sure to accept it.

2 comments

0

Aw dang, you posted before me. By the way, the parameters after the UDim2 part is not necessary, they are already set by default

0

I usually like to set them myself so I know they've been set correctly, but thanks anyway.


function Hover()
    script.Parent:TweenSize(UDim2.new(0.05, 200, 0.05, 50))
end

function StopHovering()
    script.Parent:TweenSize(UDim2.new(0, 200, 0, 50))
end

function Click()
    --TODO: Make click function
end

script.Parent.MouseEnter:connect(Hover)
script.Parent.MouseLeave:connect(StopHovering)

You have to create a UDim2 object using UDim2new(). Don't forget, there are more parameters that will allow greater customization!

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