Hi there, I have a script that passes a part on to another player when they are touched by the object. The issue is, is that I’ve tried to set the orientation and position of the part’s position to the hit’s position. This throws me the attempt to index nil with Orientation/Position. I’ve tried adding vector3.new to the hits, but still doesn’t work.
humanoid.Touched:Connect(function(hit, limb)
if hit.Parent:FindFirstChild("Torso") and hit.ClassName == "Part" then
local hittorso = hit:FindFirstAncestor("Torso")
local hithead = hit:FindFirstAncestor("Head")
humanoid = hit:FindFirstAncestor("Humanoid")
print(hit.ClassName)
Part0.Parent = hittorso
Part1.Parent = hittorso
weld1.Part1 = hittorso
Part0.Orientation = hittorso.Orientation + Vector3.new(-90,0,0)
Part0.Position = hittorso.Position + Vector3.new(0,0,-0.75)
Part1.Position = hittorso.Position
beeping.Parent = hithead
beeped.Parent = hithead
explosionsfx = hithead
end
end)
Wouldn’t it meant to be hit.Parent instead of just hit? I think you should try checking on the Parent and also try using FindFirstChild instead of FindFirstAncestor
Well I’m making a local variable here so I don’t need to write that line of code every single time, also findfirstchild wouldn’t work since I’m trying to find the ancestory of the hit part
What i meant is that you should check on the hit’s Parent, As if you want to damage a Player, You would need to use hit.Parent:FindFirstChild("Humanoid") to retrieve the Humanoid, And to (probably) retrieve the Torso and Head you would need to do the same thing.