I used a lot of YouTube tutorials but none worked and An issue might just be that I also have another leaderstats but it seems fine But that’s not the issue. so the issue is that when I kill a player I don’t get a reward
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local cash = Instance.new("IntValue",leaderstats)
cash.Name = "Cash"
cash.Value = 0
local kills = Instance.new("IntValue",leaderstats)
kills.Name = "Kills"
kills.Value = 0
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function(killed)
local CreatorTag = character.Humanoid:FindFirstChild("creator")
if CreatorTag and CreatorTag.Value then
local stats = CreatorTag.Value:WaitForChild("leaderstats")
stats["Cash"].Value = stats["Cash"].Value + 20
stats["Kills"].Value = stats["Kills"].Value + 1
end
end)
end)
end)
Can I see the damaging part of the sword script? It would help if I could add a part to it to make sure that it creates the creator tag and defines it.
Handle.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= Tool.Parent then
if Debounce == true and PlayersHit[Hit.Parent] == nil then
Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(30)
PlayersHit[Hit.Parent] = true
wait(1)
PlayersHit[Hit.Parent] = nil
end
end
end)
Handle.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent ~= Tool.Parent then
if Debounce == true and PlayersHit[Hit.Parent] == nil then
local hithum = Hit.Parent:FindFirstChild("Humanoid")
if hithum.Health > 0 then
hithum:TakeDamage(30)
if hithum.Health <= 0 then
local creatortag = hithum:FindFirstChild("creator") or Instance.new("ObjectValue")
creatortag.Name = "creator"
creatortag.Value = game.Players:GetPlayerFromCharacter(Tool.Parent)
creatortag.Parent = hithum
end
end
PlayersHit[Hit.Parent] = true
wait(1)
PlayersHit[Hit.Parent] = nil
end
end
end)