I’m attempting to make a karma system for those of which who kill players that arnt intended to be killed, however, I’ve come across an issue.
The chunk of code in the gun:
Gun Code
…
h:TakeDamage(damage)
print(h.Health) -- h being the humanoid of the player that got shot
if h.Health <= 0 then
print("Deathed")
game.ReplicatedStorage.Event:Fire("DeadByPlayer",h.Parent.Name,script.Parent.Parent.Name)
end
And this is what catches it:
…
if MPS:UserOwnsGamePassAsync(v.UserId,TwoTimesGhostGamepassID) == true then
table.insert(GhostChance,1,v.Name) -- add it twice
table.insert(GhostChance,1,v.Name)
else
table.insert(GhostChance,1,v.Name) -- else add it once
end
end
local ChosenGhost = GhostChance[math.random(1,#GhostChance)]
..........
game.ReplicatedStorage.Event.Event:Connect(function(Key,PlayerDeadName,PlayerName)
if Key == "DeadByPlayer" then
print("CORE:".. PlayerDeadName,ChosenGhost)
if tostring(PlayerDeadName) ~= tostring(ChosenGhost) then
game.ReplicatedStorage.Event:Fire(PlayerName,-10,"KarmaChanged")
print("Sent Over To DataStore")
end
Ive played this multiple times and the print in the event function always prints “CORE: Revelted Revelted” meaning PlayerDeadName and ChosenGhost are both Revelted.
HOWEVER! The function still continues, and gives the player who killed the ghost -10 karma.
I for the life of me cannot figure out how to fix this. If anyone has any ideas, HMU!