Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My sound to head through GUI click wont work. How do I fix this?

function OnClicked(clicked)
	local sound1 = Instance.new("Sound")
	sound1.SoundId = "http://www.roblox.com/asset/?id=1571597070"
	sound1.Looped = false
	sound1.Volume = 0.5
	local player = game.Players.LocalPlayer
	local char = player.Character
	local head = char:WaitForChild('Head')
	sound1.Parent = head
	sound1:play()
end
script.Parent.MouseButton1Click:connect(OnClicked)

An error in the output keeps showing up saying "00:01:17.299 - Players.Zvtu.PlayerGui.ScreenGui.Frame.TextButton.Script:7: attempt to index local 'player' (a nil value)". What does that mean? How do I make this script so the sound plays through the players head? Any help would be appreciated.

1 comment

0

ServerScript Used.

1 answer

Only reason this wouldn't work is if you have it in a serverscript instead of a local.

This discussion is preserved as it was. New answers, comments, and votes are closed.