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

Gui Script Not activating? [SOLVED]

Asked by 8 years ago
Edited 7 years ago

I was just trying to make a simple Gui that stays on the screen for 3 seconds, then it Tweens off, but I've been having trouble with getting this to work. I've tried just disabling the visibility to test it, but it only works in studio. Help?

This is a local script in a Screen Gui. The screen Gui contains two image labels that should move off screen when the script is activated.

Here is the code:

local player = script.Parent.Parent

local mainGui = script.Parent

function testFunction()
    local folder = mainGui.SplashScreen

    local test1 = folder.test1
    local test2 = folder.test2

    wait(3)
    test1:TweenPosition(UDim2.new(-1, 0, 0, -100), "In")
    test2:TweenPosition(UDim2.new(1, 0, 0, -100), "In")
end

testFunction()

I'm new to Roblox scripting so I don't know if it's simple or not.

Thanks! -Kyleo

0
Normally when things only work in studio, it's because FE is on. You're also not using LocalPlayer so you must be using a regular script. This all means that the problem is most likely because Scripts can't access PlayerGui when FE is on. Use a local script or turn FE off. User#11440 120 — 8y
0
FE was off and it is in a Local script... I'll chance the player to local player though... Kyleocraft 25 — 8y
0
Still not working... :/ Kyleocraft 25 — 8y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Following wfvj014's advice, your script should look like this:

local player = game:GetService("Players").LocalPlayer

local mainGui = script.Parent

function testFunction()
    local folder = mainGui.SplashScreen -- What is this?

    local test1 = folder.test1
    local test2 = folder.test2

    wait(3)

    test1:TweenPosition(UDim2.new(-1, 0, 0, -100), Enum.EasingDirection.In)
    test2:TweenPosition(UDim2.new(1, 0, 0, -100), Enum.EasingDirection.In)
end

testFunction()

if your explorer looks like this:

StarterGui
    ScreenGui
        LocalScript
        SplashScreen
            test1
            test2

Then I don't see anything wrong with your script.

PS: You should also probably change the test1 and 2 to Test1 and 2, and change

local test1 = folder.test1
local test2 = folder.test2

to

local test1 = folder.Test1
local test2 = folder.Test2
Ad

Answer this question