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

How to make an unanchored object when touched?

Asked by 9 years ago

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

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
9 years ago

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)
Ad

Answer this question