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

Unable to cast string to token, gui tweening error?

local client
client['MessageTweenAnimate']={"Top","Bottom","Sine","Out"}; 
bg:TweenPosition(
	UDim2.new(0,0,0,0),
	client.MessageTweenAnimate[3],
	client.MessageTweenAnimate[4],
	.8,
	true
)

Error: Unable to cast string to token. Script ' --- ' Line 3 - field ?

Should I use numbers instead?

1 answer

It might help a bit if we knew what bg was, but I think I see your issue.

I'm not sure if I'm right, I can't test my theory since I can't get ROBLOX Studio to work at this time. But I'm pretty sure that went you call for client.MessageTweenAnimate You need to do client["MessageTweenAnimate"][3] Or you could do something like this:

local MessageTweenAnimate = {
	"Top", --Assuming "Top" and "Bottom" are positions? I don't think "Top" and "Bottom" are in :TweenPosition() arguments.
	"Bottom",
	"Sine",
	"Out"
}

bg:TweenPosition(UDim2.new(0, 0, 0, 0), MessageTweenAnimate[4], MessageTweenAnimate[5], 0.8, true)

Another issue is you used "Sine" first and then used "Out". It's the other way around. You need to define the direction, and THEN you can define the style. Also, if bg is a ScreenGui, then it won't work. Tweening positions and sizes only works on Gui elements like TextBoxes, TextLabels, TextButtons, ImageLabels, Frames, ScrollingFrames, ImageButtons, etc.

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