https://developer.roblox.com/en-us/articles/weapons-kit
how to make a script that will understand who the killer is?
I have used many different scripts but they don’t work. I need If a player from the “Guard” team kills a player from the “Prisoners” team, then he becomes a prisoner to if player kill
In the gun, add this code:
local function CreateCreator(Humanoid, Player)
Humanoid:SetAttribute("Creator", Player.Name)
wait(2)
Humanoid:SetAttribute("Creator", nil)
end
And Humanoid is the player’s humanoid that was killed, and Player is the person who killed them.
Idk how the gun kit works, so you are on your own to figure out how to use in the Killed player function
CreateCreator(DedPerson.Character.Humanoid, Player)
CreateCreator(DedPersonHumanoid, Player)
And to detect when a player was killed, add this script in the server:
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
Character.Died:Connect(function()
local Killer = Character.Humanoid:GetAttribute("Creator")
-- Do whatever you want with the Killer here.
end)
end)
end)
3 Likes