Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to stop this error from returning?

Asked by
Axenori 124
4 years ago
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

Log in to vote
0
Answered by 4 years ago

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)
0
Still returns the error Axenori 124 — 4y
0
I think the problem is that the target itself is nil. Don't know how to fix that lol. ToppatNoob 34 — 4y
0
Probably because it's the same exact script User#29913 36 — 4y
0
I have a local script that fires the RemoteEvent, Axenori 124 — 4y
Ad

Answer this question