so idk is all in the server and here the reference:
Players.PlayerAdded:Connect(function(player)
debounceTable[player] = false
for _, v in pairs(script.PlayerData:GetChildren()) do
v:Clone().Parent = player
end
local character = player.Character or player.CharacterAdded:Wait()
character:WaitForChild("Humanoid").Died:Connect(function()
for _, v in pairs(player.Materials:GetChildren()) do
if v:IsA("IntValue") and v.Value ~= 0 then
DropModule.SpawnDrops(v.Name, character.HumanoidRootPart.Position, v.Value, 7)
v.Value = 0
end
end
end)
end)
Players.PlayerAdded:Connect(function(player)
debounceTable[player] = false
for _, v in pairs(script.PlayerData:GetChildren()) do
v:Clone().Parent = player
end
Player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
for _, v in pairs(player.Materials:GetChildren()) do
if v:IsA("IntValue") and v.Value ~= 0 then
DropModule.SpawnDrops(v.Name, character.HumanoidRootPart.Position, v.Value, 7)
v.Value = 0
end
end
end)
end)
end)
the problem with this is that character doesn’t update when the player dies, i.e. it works once, but when the character dies, a new one spawns and the character variable doesn’t update, the connection is severed. To fix this you need to add a CharacterAdded event.