I am currently editing a music system to use custom variables supplied by the developer; however, I seem to be experiencing problems doing so, is anyone able to help me?
The player keeps showing the same song name and artist and not on the right song.
Code (server script)
local enabled = false
local groupId = 100000
local groupRank = 10
local mainSpeaker = Instance.new("Sound", workspace)
local sounds = script["Sounds"]
local idList = {}
script["MusicUpdate"].Parent = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(char)
end)
Player.Chatted:connect(function(message)
if message:lower() == "skip" then
if groupId > 0 then
if Player:GetRankInGroup(groupId) >= groupRank then
if mainSpeaker then
mainSpeaker.TimePosition = mainSpeaker.TimeLength
end
end
elseif Player.userId == game.CreatorId then
if mainSpeaker then
mainSpeaker.TimePosition = mainSpeaker.TimeLength
end
end
end
end)
end)
wait(5)
if #sounds:GetChildren() > 0 then
for num,obj in pairs(sounds:GetChildren()) do
local currentId = obj.SoundId or nil
Artist = obj:WaitForChild("Artist").Value or nil
Name = obj:WaitForChild("Name").Value or nil
if currentId then
idList[num] = currentId
end
end
end
mainSpeaker.Name = "MusicPlayer"
songNumber = 1
while(enabled and wait()) do
mainSpeaker.TimePosition = 0
if #idList > 0 then
mainSpeaker.SoundId = idList[songNumber]
mainSpeaker:Play()
local event = game:GetService("ReplicatedStorage"):FindFirstChild("MusicUpdate")
event:FireAllClients(Name,Artist)
end
songNumber = songNumber + 1
if songNumber > #idList then
songNumber = 1
end
mainSpeaker.Ended:wait()
end
Reciever (local script)
local Player = game.Players.LocalPlayer
local event = game:GetService("ReplicatedStorage"):WaitForChild("MusicUpdate")
event.OnClientEvent:connect(function(songname,artist)
script.Parent.Text = songname.." by "..artist
end)