Hello, I was wondering how to fix this script. I get this error whenever it gets activated. Also more info, it's supposed to play a sound for the player and anyone else around the player.

http://prntscr.com/bc1kxk

This is the code:

local active = false

function click()
	if active == false then
		sound = Instance.new("Sound", game.Players.LocalPlayer.Character.Torso)
		sound.SoundId = "http://www.roblox.com/asset/?id=147605033"
		sound.Volume = 1
		sound.Looped = true
		sound:Play()
		script.Parent.Selected = true
		active = true
	elseif active == true then
		sound:Destroy()
		script.Parent.Selected = false
		active = false
	end
end

script.Parent.MouseButton1Down:connect(click)

11 comments

0

I this a LocalScript?

0

Its a regular script.

0

Also more info, it's supposed to play a sound for the player and anyone else around the player.

0

You can't do game.Players.LocalPlayer in a regular script, only in localscripts

0

Yeah it has to be a LocalScript

0

I've been told if its a local script, then the other players wont be able to hear the audio, only you?

0

If FE is on, then yes. Just use a remote event if you want all the players to hear it

0

What would that code look like with the remove event then?

0

its on the wiki, make take a bit of practice to understand... but its worth it in order to keep your place free from exploiters and hackers

0

Still looking for help on what the code should be. Don't understand what to make it.