Hello, so I'm currently making a script that prints out 1. Killer Name 2. Killer Weapon
Whenever I go to test it I get an error in my output saying ****Workspace.Script:12: attempt to index local 'Weapon' (a nil value)**** How would I go about fixing this? Here's my full script
Players = game:GetService("Players") Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) local Humanoid = Character:WaitForChild("Humanoid") Humanoid.Died:connect(function() if Humanoid:FindFirstChild("creator") ~= nil then local Killer = Humanoid.creator.Value local Weapon = Killer:FindFirstChildOfClass("Tool") if true then end print (Killer.Name) print (Weapon.Name) end end) end) end)
I'm not too familiar with the creator tag but I believe the issue is that creator.Value is the actual player rather than the player's character. Try adding .Character to the end of line 8 like so:
local Killer = Humanoid.creator.Value.Character
The player's humanoid has a creator
value, what type of variable is it?
If it's an object value, then it's referring to the player in game.Player
The way to fix it is to add a string value and set it as the killer, so replace it with workspace[creator.Value]
Hoped this helps!