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

How to make music play locally when a player joins?

Asked by
jvyss 16
5 years 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 — 5y
0
You can’t use PlayerAdded on the LocalPlayer, it can only Fire on the actual Player Service, rewrite line one to: game.Players Ziffixture 6913 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years 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 — 5y
0
The Sound must be in workspace to work. Ziffixture 6913 — 5y
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 Ziffixture 6913 — 5y
Ad

Answer this question