Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unanchor a model on touch ?

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

1 comment

0

This would only set anchored to false for that one part called metal, as a model does not have a touched event.

4 answers

✓ Accepted answer

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!

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.

1 comment

0

Sorry if this doesn't help

insert a script inside the part and then type:

script.Parent.touched:connect(function(hit)
	script.parent.Anchored=false
end)

2 comments

0

this should work

0

Kind of late and it will only unanchor the part of which the script was inserted to.

This discussion is preserved as it was. New answers, comments, and votes are closed.