I've got this script inside a part that is in Workspace that when someone goes over it does some code, but I began seeing this error:
attempt to index nil with 'FindFirstChild'
Here is the script:
script.Parent.Touched:Connect(function(hit)
if hit then
wait(1)
local player = nil
-- Checking to see if the part that hit it is a character
if hit.Parent:FindFirstChild("Humanoid", true) then -- this is where it is erroring
player = game.Players:GetPlayerFromCharacter(hit.Parent)
-- Special case where a hat hits the spawn rather than a limb
elseif hit.Parent.Parent:FindFirstChild("Humanoid", true) then
player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
end
end
end)

1 comment
Remove "true" on lines 7 and 10.