local debounce = false
local part = script.Parent
local interval = 4
part.Touched:Connect(function(hit)
if debounce == false then
debounce = true
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local PoisonPart = Instance.new("Part")
PoisonPart.Parent = hit.Parent
PoisonPart.Position = CFrame.Parent.HumanoidRootPart.Position
PoisonPart.Name = ("PoisonPart")
local weld = Instance.new("Weld")
weld.Part0 = ("PoisonPart")
weld.Part1 = ("HumanoidRootPart")
weld.Parent = PoisonPart
end
wait(interval)
debounce = false
end
end)
i'm trying to make a script that creates a part inside you but for some reason i get an error named "Workspace.Part.Script:10: attempt to index nil with 'HumanoidRootPart'" leading to the part being located at the spawn how do i fix this?

1 comment
"Attempt to index nil" means its trying to index a nil value (nothing) with HumanoidRootPart, in other words - it doesnt know what HumanoidRoorPart is in your script. Try finding thr HumanoidRootPart with local HRP=hit.Parent:FindFirstChild("HumanoidRootPart") and use the HRP.