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

How do I tween? This isn't working

So I wanna tween GUI's for my game and for some reason I cannot get it to work. I am using a local script as well.

local button = script.Parent
local frame = game.StarterGui.Test.Frame

button.MouseButton1Click:connect(function()
	print("Hello")
	frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), 'Out', 'Bounce', 1)
end)

This is my code so far. Can someone maybe help me on this?

Thanks.

2 comments

0

Editted for Code block.

0

What? I editted it Because I made a grammar mistake.

1 answer

✓ Accepted answer

##Problem

You're changing the StarterGui rather than the PlayerGui. Whatever is changed in StarterGui will not replicated until you respawn.


##Solution

Use the LocalPlayer value of game.Players since you're using a LocalScript and set Frame's TweenPosition through the PlayerGui of the player.


##Final Script

local button = script.Parent
local frame = game.Players.LocalPlayer.PlayerGui.Test.Frame --All I did was change the variable so the LocalPlayer which can only be achieved in a LocalScript can be found through the Players Service and have the script go into the PlayerGui object of the LocalPlayer.

button.MouseButton1Click:connect(function()
    print("Hello")
    frame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), 'Out', 'Bounce', 1)
end)

######Hopefully this answered your question, if so hit the accept answer button. If you have any questions feel free to comment below.

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