New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How to make music play locally when a player joins?

Asked by
jvyss 16
8 months ago

So for the past hour I've been trying to make a script which when a player joins it plays a little intro music piece locally. I suspect the error is in the player part but I'm not so sure.

local player = game.Players.LocalPlayer
local sound = game.Workspace.Intro

player.PlayerAdded:connnect(function()
    sound:Play()

end)
0
Or possibly the PlayerAdded part in the localscript. jvyss 16 — 8mo
0
You can’t use PlayerAdded on the LocalPlayer, it can only Fire on the actual Player Service, rewrite line one to: game.Players Feahren 1746 — 8mo

1 answer

Log in to vote
0
Answered by 8 months ago
Edited 8 months ago

You cant call a local player in a script because the script is on the server not client. Make it so the script fires a remote event to the players client. After that have a local script playing the sound when the remote event is fired. I recommend having the sound in ReplicatedStorage.

0
Okay, thanks. I'll try that right now. jvyss 16 — 8mo
0
The Sound must be in workspace to work. Feahren 1746 — 8mo
0
The Issue is also because he’s trying to use a Service Event on the LocalPlayer, this could’ve easily been resolved with rewriting line one to: game.Players Feahren 1746 — 8mo
Ad

Answer this question