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

How to stop this error from returning?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BulletEvent = ReplicatedStorage:WaitForChild("BulletEvent")
BulletEvent.OnServerEvent:Connect(function(Player,Target,Hit)
if Target.Parent:FindFirstChild("Humanoid") ~= false then
	Target.Parent.Humanoid:TakeDamage(15)
end
end)

returns " Players.XTOOTHLESX.Backpack.Tool.Script:4: attempt to index nil with 'Parent' "

1 answer

✓ Accepted answer

Try this.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BulletEvent = ReplicatedStorage:WaitForChild("BulletEvent")
BulletEvent.OnServerEvent:Connect(function(Player,Target,Hit)
if Target.Parent:FindFirstChild("Humanoid") ~= nil then
    Target.Parent.Humanoid:TakeDamage(15)
end
end)

4 comments

0

Still returns the error

0

I think the problem is that the target itself is nil. Don't know how to fix that lol.

0

Probably because it's the same exact script

0

I have a local script that fires the RemoteEvent,

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