i have this script here
local tree = workspace.Foliage:FindFirstChild("MapleTree2"):GetChildren() tree.Touched:Connect(function(hit) local char = hit.Parent local humanoid = char:FindFirstChild("Humanoid") if humanoid then tree.Anchored = false end end)
But for some reason it keeps detecting Touched as a property (from what i understand) I get this error:
18:04:34.397 - ServerScriptService.Script:3: attempt to index field 'Touched' (a nil value) 18:04:34.398 - Stack Begin 18:04:34.398 - Script 'ServerScriptService.Script', Line 3 18:04:34.399 - Stack End
Try this:
local tree = workspace.Foliage:FindFirstChild("MapleTree2"):GetChildren() for _, v in pairs(tree) do v.Touched:Connect(function(hit) local char = hit.Parent local humanoid = char:FindFirstChild("Humanoid") if humanoid then for _, part in pairs(tree) do part.Anchored = false end end end) end
You're indexing tree
as multiple objects. You cannot do a Touched
event on that. You need to take each object separately.