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

[Roblox] Unanchor Bricks Script?

Asked by 6 years ago

I would need a brick to unanchor other bricks

function ontouch
part = anchor = true

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

First, end is missing. Second, function ontouch isn't defined and is missing (), so you have to define the function by using script.Parent.Touched:connect(ontouch). Also you can't use part = anchor = true, you need to change its Anchored property by using script.Parent.Anchored = false , assuming the script is inside of the part.

local brick1 = workspace:Part1 --a part you want to unanchor
local brick2 = workspace.Part2 --another part you want to unanchor
local thisBrick = script.Parent
function ontouch()
    brick1.Anchored = false
    brick2.Anchored = false
end
thisBrick.Touched:Connect(ontouch)

I recommend browsing through the Roblox Wiki to learn more about Lua since it seems you do not know how to use functions and properties correctly. If this worked, please upvote and accept my answer, if not comment because I wrote this on Notepad and didn't test it. I also apologize in advance if this is a poorly written answer, it's almost 12 AM and I am really tired. Thanks!

0
I'd recommend using WaitForChild() on those parts and 'C'onnect. Azarth 3141 — 6y
0
Whats the difference between connect and Connect? PyccknnXakep 1225 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
brick.Anchored = false

or...

local brick -- you define it

brick.Touched:connect(t)
    if t.name = "Humanoid" then
        local otherBricks = {} -- u define it
        for _, v in pairs(otherBricks) do
            if workspace:FindFirstChild(v) then
                local part = workspace:FindFirstChild(v.Name)
                part.Anchored = false
            end
        end
    end
end

Answer this question