Hello! I have made an Easter Egg in my place and I made a Gui that will pop up when the brick is touched, saying: You found an Easter Egg, The SkyHook! the Gui is in my starterGui called EggGui. It will pop up and play the victory sound but after I reset and go to the Brick and it doesn't pop up again. any way it can happen more than once?
here is the script:
function onTouched(hit) game.Players.LocalPlayer.PlayerGui.EggGui.Frame.Visible = true game.Players.LocalPlayer.PlayerGui.EggGui.Sound:Play() wait(2) game.Players.LocalPlayer.PlayerGui.EggGui.Frame.Visible = false end connection = script.Parent.Touched:connect(onTouched)
Don't save it into a variable, try this:
script.Parent.Touched:connect(function(hit) game.Players.LocalPlayer.PlayerGui.EggGui.Frame.Visible = true game.Players.LocalPlayer.PlayerGui.EggGui.Sound:Play() wait(2) game.Players.LocalPlayer.PlayerGui.EggGui.Frame.Visible = false end)
Replace the script with that and it should work. I made it connect to an anonymous function to save a bit of space. I'm not sure why you decided the save the connection in a variable, if you just declare it like I did it will work fine. I also see that you're using the LocalPlayer object, this can only be used in LocalScripts. So that may also be why it isn't working.