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

Trying to make a music player script FE and synced, but it doesn't work for some reason?

Asked by
Qawstar 32
6 years ago

Hello!

I'm trying to make a music player script FE compatible, so the script is supposed to change the ID everytime the last song ends and also show the song's name and I've figured these things out.

But the last things what I need help with is to make the script work so the songs are playing for everyone SYNCED. So... When someone joins the game/server, the new player hears it like the others so it doesn't start the ENTIRE playlist over for the new player.

I'm pretty sure that it needs RemoteFunctions or RemoteEvents, but here's the scripts...!:

MAIN SCRIPT WHERE ALL THE SONGS ARE:


local NP = game.StarterGui.MenuGUI.MenuFRAME.MusicFRAME.NowPlaying.Text local MP = game.ServerStorage.MusicPlayer.SoundId game.ReplicatedStorage.MusicRE.OnServerEvent:Connect(function() NP = "Tsunami Hardstyle" MP = "rbxassetid://142720946" MP.Play() MP.Ended:Wait() print("If you see this on the OUTPUT, the script should be working.") end)

THE REMOTE-EVENT TRIGGER:


game.Players.PlayerAdded:Connect(function(player) game.ReplicatedStorage.MusicRE:FireServer() end)

Hopefully someone can help, thank you for reading! :)

1 answer

Log in to vote
0
Answered by
HaveASip 494 Moderation Voter
6 years ago
Edited 6 years ago

You have many errors in ur script. You cant get player's gui from server script and more. So here is the fixed script. You have errors on 1,7,8 lines, and in client script on 1 line

---[[ Server script ]]---
local MP = game:GetService("ServerStorage"):WaitForChild("MusicPlayer")

game:GetService("Players").PlayerAdded:Connect(function(player)
    local Event = game:GetService("ReplicatedStorage").MusicRE
    Event:FireClient(player)
    MP.SoundId = "rbxassetid://142720946"
    MP:Play()
    MP.Ended:Wait()

    print("If you see this on the OUTPUT, the script should be working.")
end)

---[[ Client Script ]]---
local Event = game:GetService("ReplicatedStorage").MusicRE
local player = game:GetService("Players").LocalPlayer
local NP = player.PlayerGui.MenuGUI.MenuFRAME.MusicFRAME.NowPlaying.Text

Event.OnClientEvent:Connect(function()
    NP = "Tsunami Hardstyle"
end)
Ad

Answer this question