This has been solved so the thread is closed now.
Sorry im a bit new to scripting and need help
i cant write the script rn because im on my phone but when a player dies, check how many kills they have and add it on to the killer’s stats, idk how to better explain it
If this is a sword fighting game, you need to use a “tag” method. That’s really the only way. Fortunately the roblox classic sword script already implements this. When you kill a play with the sword, it creates a tag in the character’s humanoid. An object value to the player who killed them. If you’re using classic swords in your game, you need to find the value. It’s called “creator”. Or, if you’re not using classic swords, implement that method yourself by creating a tag in the character when you kill them.
It already adds 1+ kill when i kill a player but i also want the script to steal all the kills the player has just like the steal time game but i have no idea how i can modify my leaderboard script to do that sadly
?, Simply just remove the players kills, using Players:GetPlayerFromCharacter(character)
and then add those kills to your player.
How can I add it to my leaderboard script? which line should I edit. I am completely new to scripting and lost
Here’s a basic example:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
local creator = char.Humanoid:WaitForChild("creator", .2).Value -- wait for the creator value tag, but provide a timeout, because the player might reset, therefore no creator tag.
if creator then
creator.leaderstats.Kills.Value += 1 + plr.leaderstats.Kills.Value
plr.leaderstats.Kills.Value = 0
end
end)
end)
end)
Ok thanks and that belongs in ServerStorage?
No, it’s a server script. It goes in serverscriptservice.
Oops meant to say that, thank you i tested it out and it works perfectly.
Wish I could like the post but i have reached my limit
Sorry but you shouldn’t do this, now maybe there’s people that had your same problem and the solution is here, but you “eliminated” the topic, so they will have to make a duplicate, so please don’t “eliminate” topics like this
I was just about to tell him that, but I let it go, because he’s probably a beginner. People would probably find this post anyways based on what we’re talking about inside.
Sorry, didn’t want to be mean
Char
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.