What is wrong with my script?

Hello, everyone!
While scripting a button that would stop a sound and make and make an image invisible, the button wouldn’t work, anyone can help me?
here are the script and explorer:
edit: I am using the reset ventilation

script.Parent.MouseButton1Click:Connect(function()
    game.StarterGui.ScreenGui1.Frame.sound2:Stop()
    game.Players.LocalPlayer.PlayerGui.Cameras.Frame.Visible = true
end)

https://gyazo.com/96613accbceb8c92bccd08557a8a940c

1 Like

Can you try to print after clicking the button?

Sample:

script.Parent.MouseButton1Click:Connect(function()
    print("works")
    game.StarterGui.ScreenGui1.Frame.sound2:Stop()
    game.Players.LocalPlayer.PlayerGui.Cameras.Frame.Visible = true
end)

If the print doesn’t succeed, that means something is wrong with the button. Maybe you forget to enable it. If succeed, that means something is wrong with line 2 or/and 3. Let me know!

EDIT: You said you want to make an image invisible. You are supposed to make the visible false, not true.

sorry about that, I wanted to make it invisible

but no, it doesn’t print anything

Are you sure it doesn’t print? It’s possible you forget to enable the button.

1 Like

Make sure it is active as well. Maybe that would help.

2 Likes

it gives me an underline error on the end

Is this a local script or a normal script?

it is a local script, should I use a server script?

Uh, it shouldn’t be an error. Can you send the script here again?

1 Like

script.Parent.MouseButton1Click:Connect()
print(“work”)
game.StarterGui.ScreenGui1.Frame.sound2:Stop()
game.Players.LocalPlayer.PlayerGui.Cameras.Frame.Visible = false
end

script.Parent.MouseButton1Click:Connect()
print(“work”)
game.StarterGui.ScreenGui1.Frame.sound2:Stop()
game.Players.LocalPlayer.PlayerGui.Cameras.Frame.Visible = false
end)

Add parenthesis to ‘end’.

1 Like

Can you send a photo of your explorer. I need to see the starterGui to help you.
I had the same mistake

https://gyazo.com/b50b30822ee48224cce88a69e9ef9817

script.Parent.MouseButton1Click:Connect(function()
    print("works")
    script.Parent.Parent.Parent.Parent.ScreenGui1.Frame.sound2:Stop()
    game.Players.LocalPlayer.PlayerGui.Cameras.Frame.Visible = true
end)

Try this

Ohh! You forgot to add “function”. My apologies!

It’s okay, thanks for the support!

1 Like