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

How do you tween a Text button in a frame?

Asked by 5 years ago

Im very new to lua code so this is probably simple this is the code I have:

local button = game.StarterGui.PlayScrene.Screne.Play
local PlayButton = game.StarterGui.PlayScrene.Screne.Play
player = game.Players.LocalPlayer
local object = game.StarterGui.PlayScrene.Screne
local click = game.Workspace.Click
object.Position = UDim2.new(0, -object.Size.X.Offset, 2, 0)

button.MouseButton1Click:connect(function()
    object:TweenPosition(UDim2.new(-0.35, 0,0.35, 0))
end)

Im using a local script in the ScreenGui

(Yes I know some stuff is mispelled)

When I play it, it doesnt do anything when I click the button also if you are wondering the button name is Play.

Thanks

0
I want the button to go up off the scene when clicked EmeraldRailYT 8 — 5y

1 answer

Log in to vote
1
Answered by
Leamir 3138 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Hello, EmeraldRailYT!

Your script was correctly moving the gui, but you was moving the gui inside game.StarterGui, that is just the gui that is clonned inside the player when they join.

I just needed to change the gui from game.StarterGui to game.Players.LocalPlayer.PlayerGui

local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui") -- waits for the gui to be clonned inside the player...

local button = playerGui.PlayScrene.Screne.Play
local PlayButton = playerGui.PlayScrene.Screne.Play
local object =playerGui.PlayScrene.Screne
local click = game.Workspace.Click

object.Position = UDim2.new(0, -object.Size.X.Offset, 2, 0)

button.MouseButton1Click:connect(function()
    object:TweenPosition(UDim2.new(-0.35, 0,0.35, 0))
end)
Ad

Answer this question