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 8 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 — 8y

4 answers

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

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

1game.Workspace.Fence.PART.Touched:connect(function()
2 
3 
4end)

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

1game.Workspace.Fence.PART.Touched:connect(function()
2 
3    for i,v in pairs(game.Workspace.Fence:GetChildren()) do
4        if v:IsA("Part") then
5            v.Anchored = false;
6        end
7    end
8 
9end)

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 8 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 — 8y
Log in to vote
0
Answered by 8 years ago

Thank you all !

Log in to vote
0
Answered by 6 years ago

insert a script inside the part and then type:

1script.Parent.touched:connect(function(hit)
2    script.parent.Anchored=false
3end)
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 — 6y

Answer this question