so i have this nightvision script and i want to make the de activate sound to play when the player clicks on the button again
my script:
script.Parent.ClickBox.MouseButton1Click:Connect(function() script.Parent.Activate:Play() game.Lighting.NightVisionColor.Enabled = not game.Lighting.NightVisionColor.Enabled end)
so i made it thanks and it works but i made a diffrent one with key binds and it dosent seem to work
local UserInputService = game:GetService("UserInputService") local actoov = false local function onInputBegan(input, gameProcessed) if input.UserInputType == Enum.KeyCode.Y then game.Lighting.NightVisionColor.Enabled = not game.Lighting.NightVisionColor.Enabled if actoov == false then script.Parent.Activate:Play() actoov = true elseif actoov == true then script.Parent.Deactivate:Play() actoov = false end end UserInputService.InputBegan:Connect(onInputBegan) end
you can make a variable = true(or false, its up to you, really doesn’t matter) and u can write something similar to this ( i’m a script rookie so maybe i’m wrong):
local Hotdogs = false script.Parent.ClickBox.MouseButton1Click:Connect(function() if Hotdogs == false then play your sound Hotdogs = true elseif Hotdogs == true then play the other sound Hotdogs = false end end)