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

Unanchor a model on touch ?

Asked by 7 years ago

Fence = game.Workspace.LMF.Metal

function onTouch(Part)

Fence.Anchored = false

end

Fence.Touched:connect(onTouch)

That up there is what I tried to make,no results...

I even used model scripts to look the differences and possibly fix it,nothing aswell...

If anyone knows,please write a fixed version of mine,I'd be really thankful

PS:The model I try to unanchor is a metal fence>Large Metal Fence-LMF

0
This would only set anchored to false for that one part called metal, as a model does not have a touched event. User#5423 17 — 7y

4 answers

Log in to vote
0
Answered by
Arystov 45
7 years ago
Edited 7 years ago

First, you need to detect when the user touches something that is a child of a model.

game.Workspace.Fence.PART.Touched:connect(function()


end)

Now, you need to iterate through the entire model and unanchor it.

game.Workspace.Fence.PART.Touched:connect(function()

    for i,v in pairs(game.Workspace.Fence:GetChildren()) do
        if v:IsA("Part") then
            v.Anchored = false;
        end
    end

end)

You may want to make it detect more than just a Part.

Edit: You might also want to make it recursive!

Ad
Log in to vote
0
Answered by 7 years ago

Models do not have touched events, so I recommend placing a transparent block around the model you want to trigger the function and use that block as the new trigger. Kingdom5 already answered this but I think this might help too.

0
Sorry if this doesn't help Kakitoku 32 — 7y
Log in to vote
0
Answered by 7 years ago

Thank you all !

Log in to vote
0
Answered by 6 years ago

insert a script inside the part and then type:

script.Parent.touched:connect(function(hit)
    script.parent.Anchored=false
end)
0
this should work kareemkamal 0 — 6y
0
Kind of late and it will only unanchor the part of which the script was inserted to. LordTechet 53 — 5y

Answer this question