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

Can someone help me fix this GUI Positioning and Transparency script?

--lOCATORS--
-----------------------------------------
local Base = script.Parent

local Shade = script.Parent.Shade

local Back = script.Parent.Back

local Image = script.Parent.Back.ImageLabel
-----------------------------------------

Image:TweenPosition(UDim2.new(0,0,0,0), UDim2.new(0.3, 0,0.25, 0),"out","Bounce",6)


wait(2)

for i=1,100 do
	wait(0)
	
	Shade.BackgroundTransparency = Shade.BackgroundTransparency + 0.09
	
	Back.BackgroundTransparency = Shade.BackgroundTransparency + 0.05
	
	Image.BackgroundTransparency = Image.BackgroundTransparency + 0.05
	
	Image.ImageTransparency = Image.ImageTransparency + 0.03
	
	
	
end

08:49:23.047 - Unable to cast string to token

I'm not sure how to fix the error above, can someone help me?

2 answers

✓ Accepted answer

The method TweenPosition only uses one UDim2 which is the end position.

In your code you had two.

Image:TweenPosition(UDim2.new(0,0,0,0), UDim2.new(0.3, 0,0.25, 0),"out","Bounce",6)

I would also recommend that you use Enums instead of the strings.

Image:TweenPosition(UDim2.new(0.3, 0,0.25, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 6)

Hope this helps.

3 comments

0

Ohhhh. My bad, I was using the wiki and they repeated the code. ohwell

0

Also, whats the difference between Enums and strings? I've never heard of Enums, or seen them in scripts o-o'

1

Here is a SH question on it that can explain in more detail https://scriptinghelpers.org/questions/33283/enumeration-problems-that-i-do-not-get

I just fixed your code based on the errors you have though there can be a lot more improvements you can make.

Image:TweenPosition(UDim2.new(0.3,0,0.25,0), "out", "Bounce", 6)
repeat wait() until Image.Position == UDim2.new(0.3,0,0.25,0)

repeat wait()
	Shade.BackgroundTransparency = Shade.BackgroundTransparency + 0.09
	Back.BackgroundTransparency = Back.BackgroundTransparency + 0.05
	Image.BackgroundTransparency = Image.BackgroundTransparency + 0.05
	Image.ImageTransparency = Image.ImageTransparency + 0.03
until Shade.BackgroundTransparency >= 1 and Back.BackgroundTransparency >= 1 and Image.BackgroundTransparency >= 1 and Image.ImageTransparency >= 1

I also noticed that you are hiding the { Shade, Back, Image } ?

BackgroundTransparency = 1 is when its hidden and 0 is when its displayed ImageTransparency = 1 is when its displayed and 0 when its hidden.

What your error was When using TweenPosition you have ( EndLocation, Direction, Style, Speed ) You have to position the GUI manually at 0,0,0,0 and then have the script tween it to EndLocation... or whatever

You can read more about tweening here: http://wiki.roblox.com/index.php?title=Tweening

2 comments

0

Oh thank you, and I think I,v pairs work better for my situation ^^'

0

I just tried the script out, It doesn't work and repeats the same error. and after rereading your post You sorta got some of that stuff wrong? =u='

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