Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Zvtu 4
5 years ago
01function OnClicked(clicked)
02    local sound1 = Instance.new("Sound")
03    sound1.SoundId = "http://www.roblox.com/asset/?id=1571597070"
04    sound1.Looped = false
05    sound1.Volume = 0.5
06    local player = game.Players.LocalPlayer
07    local char = player.Character
08    local head = char:WaitForChild('Head')
09    sound1.Parent = head
10    sound1:play()
11end
12script.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.

0
ServerScript Used. Zvtu 4 — 5y

1 answer

Log in to vote
1
Answered by
Robowon1 323 Moderation Voter
5 years ago

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

Ad

Answer this question