ok so, im looking to make a script that has if you touch the brick, it will unanchor and fall over.
i am very new to scripting :( so i dont know how to unanchor with scripts.
ok so, im looking to make a script that has if you touch the brick, it will unanchor and fall over.
i am very new to scripting :( so i dont know how to unanchor with scripts.
Someone kind of beat me to this. But this script is different:
local Part = script.Parent -- defining the part
Part.Touched:Connect(function(hit) -- Function activates when being touched.
-- hit is the thing that touched the part
if game.Players:GetPlayerFromCharacter(hit.Parent) then
-- Checks to see if player touched the part
Part.Anchored = false -- sets Boolean value of anchored of part
-- to false
end
end)
Part.Anchored = true
Create a Script and place it inside the part, then write this code inside. I also recommend reading the Wiki page about Anchoring Parts, and Properties in general.
local Part = script.Parent -- Referencing the part
Part.Touched:Connect(function() -- When the part is Touched then
Part.Anchored = false -- Set the Part's anchored property to false
end)
This isn't the most efficient way because the baseplate or other inanimate objects can activate the function.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
thank. i tried a script with Part.Anchored and it didnt work but i guess that is the right way