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

Why does the part spawn higher than where it should?

I'm making a gun and when the gun shoots this script is put into the bullet when the bullet hits an object it should create a black part that gets stuck inside the object but it doesn't for some reason?

it instead spawns ontop of the object it hit i'm pretty sure it has something to do with line 13 even though it doesn't give me an error in the output..

here's my script

script.Parent.Touched:connect(function(hit)
    if hit.Parent.Humanoid then
        hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health -10
    end
end)
--beyond this point is an error be careful!
script.Parent.Touched:connect(function(hit)
    local p = Instance.new("Part", workspace)
    p.Position = script.Parent.Position
    p.FormFactor = "Custom"
    p.Size = Vector3.new(0.2, 0.2, 0.2)
    p.Color = Color3.new(0, 0, 0)
p.CFrame = p.CFrame + p.CFrame.lookVector * 0.195
p.Anchored = true
end)

1 answer

✓ Accepted answer

Try changing p.Position and script.Parent.Position on line 9 to CFrame instead of Position. CFrame allows you to move parts into each other, while position raises it so that it goes to the closest position where parts don't intersect with each other.

3 comments

0

It still goes to the top of the part but not as high now

0

I fixed It thanks to you :D

0

No problem.

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