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

My tween positions are just not functioning.. Am I doing something wrong?

local Gui = game.StarterGui.AnnounceGui
local active = false
local end_Position = UDim2.new(0.049, 0, 0.62, 0)


Gui.Frame:TweenPosition(
end_Position,
Enum.EasingDirection.Out,
Enum.EasingStyle.Back,
1,
false)

I had it originally so when you pressed a click detector it would do the tween but even without it it just flat out doesn't work.

1 answer

You're indexing StarterGui instead of a player's PlayerGui. Try this resource for more explanation.

You should use a LocalScript and index for the Players.LocalPlayer, then that LocalPlayer's PlayerGui's AnnounceGui.

local Players = game:GetService("Players")

local Client = Players.LocalPlayer
local PlayerGui = Client:WaitForChild("PlayerGui")

local Gui = PlayerGui:WaitForChild("AnnounceGui")
local Frame = Gui:WaitForChild("Frame")

local active = false
local end_Position = UDim2.new(0.049, 0, 0.62, 0)

Frame:TweenPosition(
    end_Position,
    Enum.EasingDirection.Out,
    Enum.EasingStyle.Back,
    1,
    false
)

If you want to use a ClickDetector with a Script you can try something like this:

local ClickDetector = --// Path to your ClickDetector; chould be script.Parent if you put the Script in a ClickDetector

ClickDetector.MouseClick:Connect(function(Player)
    local PlayerGui = Player:WaitForChild("PlayerGui")

    local Gui = PlayerGui:WaitForChild("AnnounceGui")
    local Frame = Gui:WaitForChild("Frame")

    local active = false
    local end_Position = UDim2.new(0.049, 0, 0.62, 0)

    Frame:TweenPosition(
        end_Position,
        Enum.EasingDirection.Out,
        Enum.EasingStyle.Back,
        1,
        false
    )
end)

I suggest trying to connect a RemoteEvent though, and use a LocalScript and ServerScript.

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