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

How Do I Make Instance Stay In Place and Go Throught Blocks?

Asked by 8 years ago

Hey, I am making a mini nuke that explodes when you touch part. It works, but when it expands, it always keeps touching the top of the baseplate and doesn't go through the baseplate. How can I stop this from happening? Here is my script:

notBeenTouched = true
wait(4)
function onTouch(hit)
    HumanoidIsTrue = hit.Parent:FindFirstChild("Humanoid")
    if notBeenTouched and HumanoidIsTrue then   
    notBeenTouched = false  
    NukeBall = Instance.new("Part", Workspace)
    function onBombTouch(Hit)
    Hit:BreakJoints()
end 
    NukeBall.Touched:connect(onBombTouch)       
    NukeBall.Shape = "Ball"
    NukeBall.BrickColor = BrickColor.new("Deep orange")
    NukeBall.CanCollide = false 
    notBeenTouched = false  
    NukeBall.Anchored = true
    NukeBall.Position = Vector3.new(0, 0, 0)
    for i = 5, 100, 5 do    
    print(i)
    NukeBall.Size = Vector3.new((i), (i) ,(i))          
    wait(0.1)       
    end
    NukeBall.Transparency = 0.5
    wait(0.5)   
    NukeBall.Transparency = 1
    NukeBall:remove()
    notBeenTouched = true
    end
end

script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by 8 years ago

When a part is resized, it works the same as trying to change the position of a part into another part instead of using CFrame, this causes it to move to the very top of the parts on-contact. Now, how do we solve this problem? We must continuously put the - In this case - NukeBall CFramed into a position. It seems that you want the NukeBall at position (0,0,0). So, we fix this by instead of doing NukeBall.Position = Vector3.new(0,0,0), we use CFrame which ignores collision, NukeBall.CFrame = CFrame.new(0,0,0).

Finished Code Bellow, Please toss a Plus 1 rep and accept this answer if this helps and comment any questions or problems to this answer! :

notBeenTouched = true
wait(4)
function onTouch(hit)
    HumanoidIsTrue = hit.Parent:FindFirstChild("Humanoid")
    if notBeenTouched and HumanoidIsTrue then   
    notBeenTouched = false  
    NukeBall = Instance.new("Part", Workspace)
    function onBombTouch(Hit)
    Hit:BreakJoints()
end 
    NukeBall.Touched:connect(onBombTouch)       
    NukeBall.Shape = "Ball"
    NukeBall.BrickColor = BrickColor.new("Deep orange")
    NukeBall.CanCollide = false 
    notBeenTouched = false  
    NukeBall.Anchored = true
    NukeBall.CFrame = CFrame.new(0, 0, 0) -- Changed Here
    for i = 5, 100, 5 do    
    print(i)
    NukeBall.Size = Vector3.new((i), (i) ,(i))          
    NukeBall.CFrame = CFrame.new(0,0,0)-- Changed Here Too
    wait(0.1)       
    end
    NukeBall.Transparency = 0.5
    wait(0.5)   
    NukeBall.Transparency = 1
    NukeBall:remove()
    notBeenTouched = true
    end
end

script.Parent.Touched:connect(onTouch)

0
Hey, thanks for answering! I don't have enough reputation to give you +1, but when I do I will :) yoman1776 85 — 8y
0
Okay, and no problems that's why I'm here. (To help/get rep <3) alphawolvess 1784 — 8y
Ad

Answer this question