✓ Accepted answer
You are calling a function inside itself...
do this..
local function UnAnchor()
for _, v in pairs(script.Parent:GetChildren()) do
if v.ClassName == "Part" then
v.Anchored = false
end
end
end
script.Parent.Touched:Connect(function()
print("Meteor was touched by player")
UnAnchor()
end)
There were a couple of errors in your script
- you are calling a function within itself
- you have a "?" after callign your function
- you spelled unanchor wrong when using it in the touched event..
- your parenthesis on the last line was merged with end) meaning it would error
What I did... i made a loop in script.Parent:GetChildren() and made its anchor false when the player touches its parents brick
If this works for you, upvote and click accept please :)
2 comments
Where is this "nil value"? Is Meteor on the last code snippet defined?
it is .Name and it is "BasePart", not "Part"