Hello so i have the problem that when i kill myself i get cash what i don’t want!
code:
plr.CharacterAdded:connect(function(char)
local humanoid
repeat
humanoid = char:FindFirstChild("Humanoid")
wait()
until humanoid
humanoid.Died:connect(function()
deaths.Value = deaths.Value + 1
local tag = humanoid:FindFirstChild("creator")
if tag then
local killer = tag.Value
if killer then
local killername = killer.Name
killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
killer.leaderstats.Cash.Value = killer.leaderstats.Cash.Value + 50
killEvent:FireAllClients(plr,killername)
end
end
end)
end)
if killer and killer ~= plr then
local killername = killer.Name
killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
killer.leaderstats.Cash.Value = killer.leaderstats.Cash.Value + 50
killEvent:FireAllClients(plr,killername)
end
It would be preferable if the tag script itself wouldn’t be able to tag the own player as right now the player could steal his own kill, all this does is prevent the player from getting rewards if he is tagged by himself.
plr.CharacterAdded:connect(function(char)
local humanoid
repeat
humanoid = char:FindFirstChild("Humanoid")
wait()
until humanoid
humanoid.Died:connect(function()
deaths.Value = deaths.Value + 1
local tag = humanoid:FindFirstChild("creator")
if tag then
local killer = tag.Value
if killer then
local killername = killer.Name
killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
--killer.leaderstats.Cash.Value = killer.leaderstats.Cash.Value + 50
killEvent:FireAllClients(plr,killername)
end
end
end)
end)
plr.CharacterAdded:connect(function(char)
local humanoid
repeat
humanoid = char:FindFirstChild("Humanoid")
wait()
until humanoid
humanoid.Died:connect(function()
deaths.Value = deaths.Value + 1
local tag = humanoid:FindFirstChild("creator")
if tag then
local killer = tag.Value
if killer and humanoid.Parent.Name ~= plr.Name then
local killername = killer.Name
killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
--killer.leaderstats.Cash.Value = killer.leaderstats.Cash.Value + 50
killEvent:FireAllClients(plr,killername)
end
end
end)
end)