[first post so be nice :)]
Trying to make it so that if you kill someone it gives you cash. I know for a fact that the kill script works because the kill feed works. I have tried changing the variables and such but it just doesn’t work.
Here is the code
local event = game.ReplicatedStorage.KilledEvent
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char:WaitForChild("Humanoid").Died:connect(function(killed)
local killer = char.Humanoid:FindFirstChild("creator")
if killer.Value then
local killerName = killer.Value.Name
event:FireAllClients(plr, killerName)
killer.leaderstats.Cash.Value = killer.leaderstats.Cash.Value + 15
end
end)
end)
end)
You should instead set up a variable of the character’s humanoid so you don’t have to make things more of a mess and flood 1 line of the code. Anyways if necessary is there any other scripts that will add a creator tag value to the humanoid?
The if statement requires the creator value inside the humanoid to exist and have an existing value, anyways why is “killer.Value.Name” there? I think you can just replace it with “killer.Value” while having the value as a string of the killer’s name. Some of the scripts are fine.
killer.Value.Name is for the killfeed (shows who killed who) but i removed that so i will clean it up now. ty
no other creator scripts
edit: there is a creator script in sword (so it tracks the kills)
function TagHumanoid(humanoid, player)
local Creator_Tag = Instance.new("ObjectValue")
Creator_Tag.Name = "creator"
Creator_Tag.Value = player
Debris:AddItem(Creator_Tag, 2)
Creator_Tag.Parent = humanoid
end