Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Players.AM910SK.Backpack.Rasengan.Damage and Explosion:10: attempt to index nil with 'Humanoid'?

I have a damage script inside my tool it is a server script but every time I use it says

"Players.AM910SK.Backpack.Rasengan.Damage and Explosion:10: attempt to index nil with 'Humanoid'"

It happens at line 10 in my script

here is the script:

debounce = false
player = game.Players:GetPlayers()
tool = script.Parent

script.Parent.Handle.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
		debounce = true
		hit.Parent.Humanoid:TakeDamage(50)
		print("Damage Taken")
		player.Character.Humanoid:UnequipTools(tool)
		wait(5)
		debounce = false
	end
end)

5 comments

0

wasd

0

Are you trying to fire the event once the player unequips their tool?

0

no

0

Then what

0

I am not trying to fire an event what so ever

2 answers

Usually you would want to use :WaitForChild() so hopefully the problem should be fixed like this:

player.Character:WaitForChild("Humanoid"):UnequipTools(tool)

4 comments

0

It gives me a new error "Players.AM910SK.Backpack.Rasengan.Damage and Explosion:10: attempt to index nil with 'WaitForChild'"

0

try to use a normal script instead of LocalScript or use a LocalScript instead of a normal script

0

I am usinga normal script

0

then i am not very sure

Try using :WaitForChild()

local char = player.Character or player.CharacterAdded:Wait()
char:WaitForChild("Humanoid")

Try using this:

debounce = false
player = game.Players:GetPlayers()
tool = script.Parent

script.Parent.Handle.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	local char = player.Character or plr.CharacterAdded:Wait()
        debounce = true
        hit.Parent.Humanoid:TakeDamage(50)
        print("Damage Taken")
        char.Humanoid:UnequipTools(tool)
        wait(5)
        debounce = false
    end
end)

This should work. Accept answer if it did, thanks!

3 comments

0

I am using a normal script

0

New error "Players.AM910SK.Backpack.Rasengan.Damage and Explosion:4: attempt to index nil with 'Wait'"

0

I edited my answer take a look. I am really not sure of what is happening.

This discussion is preserved as it was. New answers, comments, and votes are closed.