What is wrong with my script?

Hey guys, I was making a script that i used with a gui and changed to a surface gui, I also changed the explorer so I changed the scripts already, any thoughs?

local img = script.Parent.Parent.resetventsimg

script.Parent.MouseButton1Click:Connect(function()
    print("works")
    img.Visible = false
    script.Parent.SOUNDV:Stop()
end)

and this one

wait(5)

game.Workspace.Console.Screen.SurfaceGui.Frame.Vent_System.resetventsimg.Visible = true
game.Workspace.SOUNDV:Play()

You will need to drop the Surface GUI into StarterGUI and set the Adornee to the part.

Try to use this:

local img = script.Parent.Parent.resetventsimg

script.Parent.MouseButton1Click:Connect(function(player)
    print("works")
    img.Visible = false
    script.Parent.SOUNDV:Stop()
end)
----------------------------------------

wait(5)

game.Workspace.Console.Screen.SurfaceGui.Frame.Vent_System.resetventsimg.Visible = true
game.Workspace.SOUNDV:Play()

they are different scripts
30char

ScreenGUIs are neat because it gives each player an individual copy. This is important because you can make changes to it on each players screen individually. However Surface GUIs when placed in the workspace don’t make individual copies. Buttons won’t trigger either. If you drop the surface GUI into StarterGUI it’ll create copies for each player.
And when you set the “Adornee” it moves the GUI onto the part you want it to appear on.

ok thanks!
I don’t know that Adornee part, do you mind saying how to do it?

Inside the properties tab there is a property you can change.

You can click on that, then the part in workspace and it’ll set the value to the part.

1 Like