I really don't know what is wrong with this but I tried 2 times to get it right. :/
Not sure if I got the ' script.Parent.MouseButton1Down:connect(function() ' wrong. ;/
script.Parent.MouseButton1Down:connect(function() game.StarterGui.ScreenGui.Frame.Visible = true wait(9) game.StarterGui.ScreenGui.Frame.Visible = false end)
Here's my second try.
script.Parent.MouseButton1Down:connect(function() script.Parent.Frame.Visible = true wait(9) script.Parent.Frame.Visible = false end)
The reason your first attempt didn't work is because StarterGui is a bin. If you want to update something on a player's screen, you need to access the PlayerGui which is located in Game -> Players -> PlayerName -> PlayerGui.
If you would like to change something for every player, you could iterate through all players like this
for _,plr in pairs(game.Players:GetPlayers()) do plr.PlayerGui...... end
As for your second attempt, my only guess is that the parent of the script is the frame you're attempting to refer to. If this is the case, you should actually try the following
script.Parent.MouseButton1Down:connect(function() script.Parent.Parent.Frame.Visible = true wait(9) script.Parent.Parent.Frame.Visible = false end)
Why? This is because your script was actually referring to a frame that is underneath the same parent as the script.
I hope this helps!
Okay, the problem is that you don't have a WaitForChild. Without one, the script will only work in studio. Here is your corrected script in the most compact version it can get, enjoy!
local frame = script.Parent.Parent:WaitForChild('Frame') function onClick() frame.Visible = not frame.Visible end script.Parent.MouseButton1Click:connect(onClick)
I think you have to replace visible with remove() not sure, I made this with animation, I hope this helps
local function OnClicked() script.Parent.Parent:TweenPosition(UDim2.new(-1.2, 0,0, 0),"In","Quint",10,true) end
script.Parent.MouseButton1Click:connect(OnClicked)