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
4 years ago
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.

0
ServerScript Used. Zvtu 4 — 4y

1 answer

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

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

Ad

Answer this question