the only reason i told you to add an object value is so you can reference the player in the bullet script
local bullet = script.Parent
local HitSound = script.Parent.HitShotSound
local plr = bullet.creator.Value --this is what i meant
local leaderstats = plr:WaitForChild("toolLeaderstats")
local credits = leaderstats:WaitForChild("Credits")
local function player_check(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
if otherPart.Name == "Head" then
humanoid:TakeDamage(100)
HitSound:Play()
if humanoid.Health >= 0 then
credits.Value = credits.Value + 10
bullet:Destroy()
else
humanoid:TakeDamage(50)
HitSound:Play()
if humanoid.Health >= 0 then
credits.Value = credits.Value + 10
bullet:Destroy()
end
end
end
end
end
bullet.Touched:Connect(player_check)
game.Debris:AddItem(bullet, 10)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
if humanoid:FindFirstChild("creator") then
local FindPlayer = humanoid:FindFirstChild("creator").Value
FindPlayer.toolLeaderstats.Cash.Value += 10
end
end)
end)
end)
when the script found inside any humanoid one value named “creator” this will give money to the player (imagine the creator value is “ToxicalGamer2006” I will get 10 cash)
you could clone the “tag” value and parent it to the enemy humanoid
try this script next
local bullet = script.Parent
local HitSound = script.Parent.HitShotSound
local plr = bullet.creator.Value --this is what i meant
local leaderstats = plr:WaitForChild("toolLeaderstats")
local credits = leaderstats:WaitForChild("Credits")
local function player_check(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
local creator = bullet.creator:Clone()
creator.Parent = humanoid
if otherPart.Name == "Head" then
humanoid:TakeDamage(100)
HitSound:Play()
if humanoid.Health >= 0 then
credits.Value = credits.Value + 10
bullet:Destroy()
else
humanoid:TakeDamage(50)
HitSound:Play()
if humanoid.Health >= 0 then
credits.Value = credits.Value + 10
bullet:Destroy()
end
end
end
end
end
bullet.Touched:Connect(player_check)
game.Debris:AddItem(bullet, 10)
local bullet = script.Parent
local HitSound = script.Parent.HitShotSound
local plr = bullet.creator
local function player_check(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
local creator = bullet.creator:Clone()
creator.Parent = humanoid
if otherPart.Name == "Head" then
humanoid:TakeDamage(100)
HitSound:Play()
if humanoid.Health >= 0 then
credits.Value = credits.Value + 10
bullet:Destroy()
else
humanoid:TakeDamage(50)
HitSound:Play()
if humanoid.Health >= 0 then
credits.Value = credits.Value + 10
bullet:Destroy()
end
end
end
end
end
bullet.Touched:Connect(player_check)
game.Debris:AddItem(bullet, 10)