Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I tween? This isn't working

Asked by
FizTech 15
8 years ago

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.

0
Editted for Code block. M39a9am3R 3210 — 8y
0
What? I editted it Because I made a grammar mistake. FizTech 15 — 8y

1 answer

Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
8 years ago

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.
Ad

Answer this question