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

Gui Script Not activating? [SOLVED]

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

3 comments

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.

0

FE was off and it is in a Local script... I'll chance the player to local player though...

0

Still not working... :/

1 answer

✓ Accepted answer

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

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