The id saver is supposed to allow you to do two commands. !save [Name] -- Will save the id you are currently playing under any name you want !play [Name] -- Will play the id that is stored with the given name.
But it doesn't save or play the id, and it prints no errors.
local data = game:GetService("DataStoreService"):GetDataStore("IDLISTSTUFF")
local k = "~~~"
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("re")
local players = game:GetService("Players")
local prefix = "!"
local playerDataTable = {}
local commands = {
["play"] = function (p, args)
local c = p.Character
local hasData = false
local pdata
for id, tab in pairs(playerDataTable) do
if id == p.UserId then
hasData = true
pdata = tab
end
end
if hasData then
local isMounted = p:FindFirstChild("Mounted")
if isMounted then
local remote = rs:WaitForChild("r")
if pdata[args] then
remote:FireClient(p, "Play", pdata[args])
end
else
local tool = c:FindFirstChild("BoomBox")
local remote = tool:FindFirstChild("Remote")
if pdata[args] then
remote:FireClient(p, "Play", pdata[args])
end
end
end
end,
["save"] = function (p,args)
local c = p.Character
local hasData = false
local pdata
for id, tab in pairs(playerDataTable) do
if id == p.UserId then
hasData = true
pdata = tab
end
end
if hasData then
local isMounted = p:FindFirstChild("Mounted")
if isMounted then
local hrp = c:FindFirstChild("HumanoidRootPart")
local music = hrp:FindFirstChild("Music")
local id = string.split(music.SoundId, "id=")[2]
local alreadySaved = false
for i,v in pairs(pdata) do
if v == id then
alreadySaved = true
end
end
if not alreadySaved then
playerDataTable[p.UserId][args] = id
end
else
local tool = c:FindFirstChild("BoomBox")
local handle = tool.Handle
local music = handle:FindFirstChild("Music")
local id = string.split(music.SoundId, "id=")[2]
local alreadySaved = false
for i,v in pairs(pdata) do
if v == id then
alreadySaved = true
end
end
if not alreadySaved then
playerDataTable[p.UserId][args] = id
end
end
else
local isMounted = p:FindFirstChild("Mounted")
playerDataTable[p.UserId] = {}
local d = playerDataTable[p.UserId]
if isMounted then
local hrp = c:FindFirstChild("HumanoidRootPart")
local music = hrp:FindFirstChild("Music")
if music then
d[args] = string.split(music.SoundId, "id=")[2]
end
else
local tool = c:FindFirstChild("BoomBox")
if tool then
local handle = tool.Handle
local music = handle:FindFirstChild("Music")
if music then
d[args] = string.split(music.SoundId, "id=")[2]
end
end
end
end
end
}
players.PlayerAdded:Connect(function(player)
local pData
pcall(function()
pData = data:GetAsync(k..player.UserId)
end)
if pData then
playerDataTable[player.UserId] = {}
local d = playerDataTable[player.UserId]
for i,v in pairs(pData) do
d[i] = v
end
end
player.Chatted:Connect(function(msg)
if string.sub(msg, 1,1) == prefix then
local rmsg = string.sub(msg, 2)
local split = string.split(rmsg, " ")
local cmd = split[1]
local arg = ""
local fullmsg = ""
for i,v in pairs(split) do
if i ~= 1 then
if fullmsg ~= "" then
fullmsg = fullmsg.." "..v
elseif fullmsg == "" then
fullmsg = fullmsg..v
end
end
end
arg = fullmsg
print(arg)
for i,v in pairs(commands) do
if i:lower() == cmd:lower() then
v(player, arg)
end
end
end
end)
player.CharacterAdded:Connect(function(char)
local hum = char:FindFirstChild("Humanoid")
hum.Died:Connect(function()
local m = player:FindFirstChild("Mounted")
if m then
m:Destroy()
end
end)
end)
end)
players.PlayerRemoving:Connect(function(player)
local id = player.UserId
local key = k..id
local pd = playerDataTable[id]
if pd then
data:SetAsync(key, pd)
end
end)
