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

Turn CanCollide off in a script?

Asked by
nicros 165
8 years ago

So I'm working on an RPG but have basically no knowledge of LUA at all....tho im picking up on things and slowly am learning

so ive got a basic mining mechanic and i wanted the rock to disappear when its killed....knowing nothing i figured the easiest way would be to make it transparent and turn collision off when its 0hp

so ive got this part in my script which turns the rock transparent but idk if im doing the CanCollide wrong because its not turning CanCollide off

    elseif script.Parent.Ore.Health<1 then
    script.Parent.Rock.Transparency = 1
    wait(0)
    script.Parent.Head.Transparency = 1
    wait(0)
    script.Parent.Head.CanCollide = false
    wait(0)
    script.Parent.Torso.CanCollide = false
    wait(0)
    end

The transparency part works perfect, but when i kill the rock it turns inadvisable but i can still collide with it

1 answer

Log in to vote
0
Answered by 8 years ago

You can easily do it, it just means that your Hierarchy is wrong EX.

script.Parent.Part13.CanCollide = false

If you never want the model to be again you have a different option

elseif script.Parent.Ore.Health<1 then
script.Parent.Ore:remove() --I assume Ore is the main parent model
wait(0)
end

Make sure its Head that you don't want to collide with! If this helped, please accept!

Ad

Answer this question