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
And the script(Local)
Thanks for reading!
Have a nice day!
Also there is no error in the output
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.
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~~
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.
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.