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

Help with playing music localy on touched local script? (UNSOLVED)

I am making a new speed run, and I need it to play this audio in PlayerGui. The audio is I it, and the only problem is something about the OnTouched part (Not shown in Output, just a guess). (This is a LocalScript)

script.Parent.OnTouched:connect(function(hit, player)
	local songs = game.Players.LocalPlayer.PlayerGui.Music
songs.Level1:Stop()
songs.Level1:Play()
end)

Thanks in advance!

2 comments

0

Have you looked in output if there is a error?

0

^^^ There is an error (he just said it). What is the error that is "something about the OnTouched part." You can see it at output in view.

1 answer

script.Parent.Touched:connect(function(hit, player)
	local songs = game.Players.LocalPlayer.PlayerGui.Music
	songs.Level1:Stop()
	songs.Level1:Play()
end)

Fixed, for you. You put 'OnTouched', when the event is supposed to be 'Touched'.

4 comments

0

Thanks so much! I just realized that I needed to put this in a server script.

0

No problem, but putting it in a server script will make it play globally (everyone in the server will hear it). To make it work in a local script, I recommend removing the variables 'hit' and 'player' on line 1. I would also appreciate if you accepted the answer so that this thread closes. :)

0

Thanks! I'll try it.

0

It doesnt work in a local script

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