My gui is not tweening and I have searched the whole internet

I’m trying to make a screen fade effect when entering a door (Just like adopt me) but my gui tween is not working. I thought it might be that touched function does not work with gui’s so i changed it to a surface gui with a button. But still no tween.
Here is a video
https://streamable.com/low1cg
Screenshot of my explorer
Imgur
And the script(Local)
Imgur

Thanks for reading!
Have a nice day!
Also there is no error in the output

3 Likes

Also, click the pics because its not showing the whole image

I think because you’re using

UDim2.new(0,0,0,0)

And it should be like this

UDim2.new(0,0,0)

I will try that one give me a second.

Nope it doesn’t work. Maybe it is supposed to be a 4 number value.

You would probably find this in the output window, but your GUI likely doesn’t exist when the script runs.

local GUI = game.Players.LocalPlayer.PlayerGui:WaitForChild( 'TeleportBlackScreen' ):WaitForChild( 'Frame' )

Always check the output window first.

In future, it is far easier to paste the code directly here using three backticks to format it ``` at the start and end. And try to upload images directly to avoid the cropping issue and to avoid people having to go to an external site just to help with your issue.

Edit: Forgot about where LocalScripts can run. See solution in my next reply.

I did but there is no error lemme fix dat
Edit: Nope the wait for child is not doing anything

Your error is that LocalScripts don’t run in workspace. Fire a remote event if you want to communicate to the client.

~~Make sure that the ScreenGui is enabled (ScreenGui.Enabled == true) and that the Frame is visible. You should be able to see them both on your screen in Studio and they should not be left disabled or invisible by any script. While Testing, check both the ScreenGui and the frame to make sure that they are enabled and visible.

If they are both fine and you still don’t know a solution, print a debug statement when you click the button: print("The button has been clicked") to make sure~~

(ignore this blurred part)

1 Like

The frame is the black box and i will change the things you mentioned

How can i get the player who clicked the button? I’m not very good with remote events.
I mean from the server.

Another way, other than firing a remote event, is to have a LocalScript somewhere else, like in StarterCharacterScripts and then reference that button in workspace. Then detect the MouseClick event.

1 Like

You don’t need to use remote events if you’re unfamiliar with them. Put a LocalScript in the teleport GUI that finds the button in the workspace and listens for a click like you already had.

You’ll need to use WaitForChild to ensure the part and the surface GUI are all loaded in first.

Here’s a quick demo using the same hierarchy as your game. Put the LocalScript inside the TeleportBlackScreen GUI:

local GUI = script.Parent:WaitForChild( 'Frame' )
local db = false
game.Workspace:WaitForChild( 'Part' ):WaitForChild( 'SurfaceGui' ):WaitForChild( 'TextButton' ).MouseButton1Down:Connect( function()
	if not db then
		db = true
		GUI:TweenSize( UDim2.new( 1, 0, 1, 0 ), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 3 )
		wait( 3 )
		GUI:TweenSize( UDim2.new( 0, 0, 0, 0 ), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 3 )
		wait( 5 )
		db = false
	end
end)

You may want to give it a better name than Part once you have more parts in the game - ideally a unique name for the part with the button on it so that your script references the correct one.

3 Likes

Yup, that was the solution. Thanks man. I was gonna jump in the toilet and flush lol.
Have a nice day or night

3 Likes

This is very helpful because i thought the local script runs anywhere lol.
Have a nice day or night

1 Like

It is a 4 number value. Udim2 is 4 number value and Udim is 2 number value.

1 Like