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

How to make an unanchored object when touched?

I'm a beginner with coding, and I'm willing to always learn. My question is: How do you unanchor a brick or an object when touched? I have tried it and I've probably messed it up big time but here goes nothing.

local Fall = script.Parent

function steppedOn()
	if script.Parent.CheckValue == false then
		game.Players.Touched:GetPlayerFromCharacter(Fall)
		script.Parent.Anchored = false
	else
		script.Parent.Anchored = true
	end
end

Fall.Touched:connect(steppedOn)

1 answer

✓ Accepted answer

You can do:

local Fall = script.Parent

function steppedOn(hit)
    if script.Parent.CheckValue == false then
        hit.Anchored = false --this line makes whatever touched the par (script.Parent) then that part gets unanchored.
        script.Parent.Anchored = false
    else
        script.Parent.Anchored = true
    end
end

Fall.Touched:connect(steppedOn)

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