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

Part Positioning Issues?

Asked by 9 years ago

I'm trying to make this "New Part" spawn at the exact location that I choose, if there is a block in the way, it moves up, is there a way I can force it to a certain position and make it disregard the other blocks and models?

ting = true
Dist = 100

function Touch(hit)
    if ting == true then
    local hurt = game.Lighting.PainScript:Clone()
    local boom = Instance.new("Explosion", script.Parent)
    local pain = Instance.new("Part", script.Parent)
    hurt.Parent = pain
    hurt.Disabled = false
    pain.Anchored = true
    pain.Size = Vector3.new(Dist,Dist,Dist)
    pain.Transparency = 0
    pain.Position = Vector3.new(0,0,0) --It wont go to 0,0,0 instead it moves it on top of the baseplate...
    boom.Position = script.Parent.Position
    boom.BlastPressure = 10
    boom.DestroyJointRadiusPercent = 0
    ting = false
    wait (2)
    ting = true
    end
end

script.Parent.Touched:connect(Touch)

1 answer

Log in to vote
2
Answered by 9 years ago

If you change the position it will adjust itself so It doesn't go inside a part. CFrame acts differently: It forces the part to go any point you tell it to. Also, you can use CFrame to teleport players.

ting = true
Dist = 100

function Touch(hit)
    if ting == true then
    local hurt = game.Lighting.PainScript:Clone()
    local boom = Instance.new("Explosion", script.Parent)
    local pain = Instance.new("Part", script.Parent)
    hurt.Parent = pain
    hurt.Disabled = false
    pain.Anchored = true
    pain.Size = Vector3.new(Dist,Dist,Dist)
    pain.Transparency = 0
    pain.CFrame = CFrame.new(0,0,0) --It will be inside of the baseplate. If this doesn't work then replace this line with pain.Position = CFrame.new(Vector3.new(0,0,0)) Also, notice how it says part.CFrame instead of part.Position. And I also replaced Vector3.new with CFrame.new.
    boom.Position = script.Parent.Position
    boom.BlastPressure = 10
    boom.DestroyJointRadiusPercent = 0
    ting = false
    wait (2)
    ting = true
    end
end

script.Parent.Touched:connect(Touch)


Remember when I told you about the teleporting? Well, you can do that with characters by changing their CFrame to a specific point.

workspace.Player1.Torso.Position = Vector3.new(0,0,0) --This would kill the players.

workspace.Player2.Torso.CFrame = CFrame.new(0,0,0) --This player would live.

Hope this helps!


More on CFrame/Coordinate Frame

0
Thank you so much! It worked with pain.CFrame = CFrame.new BSIncorporated 640 — 9y
Ad

Answer this question