Further Context. I have this script that gives +2 points for killing, but if you are vip it will give +4 instead. It does give the points correctly when you kill a player BUT ONLY if that player that is killed was previously killed by a sword already. Basically, every first death of a player does not reward the killer with the points.
I'm assuming I'm giving the tag wrong or something, but I don't really know. Can anyone give me some insight on what's going on?
local CandyOnKill = 2
local VIPCandyOnKill = 4
local statsData = game:GetService("DataStoreService"):GetDataStore("SaveSystem1")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
player.CharacterAdded:Connect(function(character)
local hum = character:FindFirstChild("Humanoid")
if hum then
end
character.Humanoid.Died:Connect(function()
local tagged = character.Humanoid:FindFirstChild("creator")
if tagged ~= nil then
local plr = tagged.Value
local ls = plr.leaderstats
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.userId, 1044752) then
ls.Candy.Value = ls.Candy.Value + VIPCandyOnKill
else
ls.Candy.Value = ls.Candy.Value + CandyOnKill
end
end
end)
end)
end)
