Alright, This is supposed to be a tool that kills the player. But it's telling me this: "attempted to index nil with Humanoid"
Here's the code:
local tool = script.Parent local chr = game:GetService("Players").LocalPlayer:WaitForChild("Character") script.Parent.Activated:Connect(function() chr.Humanoid.Health = 0 end)
Is it a hard fix or easy fix?
its supposed to be LocalPlayer.Character also try to define the character inside the code block when the tool is activated so that way it doesnt glitch and the character is nil because that could also be another problem
Hi! Seems like you needed some help.
So I thought that changing a few things would help, try this script:
local tool = script.Parent local chr = game.Players.LocalPlayer.Chraracter script.Parent.Activated:Connect(function() chr.Humanoid.Health = 0 end)
Hope it works!
Should I do it the dumb way instead?
Like :
script.Parent.Activated:Connect(function() script.Parent.Parent:WaitForChild("Humanoid").Health = 0 end)
I really hate this kind of scripts. But, I have to
You're calling plr.Character the wrong way. Yes, you need to wait for the Character to load, but it's supposed to be like this:
local plr = game:GetService("Players").LocalPlayer local tool = script.Parent local chr = plr.Character or plr.CharacterAdded:Wait() tool.Activated:Connect(function() chr.Humanoid.Health = 0 end)