Okay, so I’ve been scripting for two years, but now that I need to make “kill-logs,” I have no idea how to figure out who killed who and change the leaderboard accordingly. What should I do?
Maybe you should add a Touched event on the player, pass on the owner of the sword/ammo that’s touching the player, and use that to make the logs? I will experiment in studio and get back ASAP.
first you should add a script that but a creator value tag here is a tread explaining it https://scriptinghelpers.org/questions/17501/what-is-the-creator-value
then you add a script when the player join it get the character and when the player dies it will get that creator value or tag (which is the player that killed the other player) then reward him like this:
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
hum.Died:Connect(function()
if char:FindFirstChild("creator") then
local plr = creator.Value
plr.leaderstats.Kills += 1
end
end)
end)
end)
3 Likes
I was able to re-create a much simpler way using the Roblox classic sword, take a look:
script.Parent.Handle.Touched:Connect(function(hit)
hit.Parent.Humanoid.Died:Connect(function()
print(script.Parent.Parent.Name .. " killed " .. hit.Parent.Name)
end)
end)
2 Likes