In my game, you touch buildings to get points. I'm only just learning Roblox Lua, so I don't know. My game is set up like this: there is a model called ClonedMap in workspace. Inside of there, there are two folders for Large_Buildings and Small_Buildings respectively. Inside there are models for each of the buildings. How can I use the Touched function to make it detect when the player touches a building, then delete that building?
--// Variables local ClonedMap = game.Workspace:WaitForChild("ClonedMap") local Large_Buildings = ClonedMap:WaitForChild("Large_Buildings") local Small_Buildings = ClonedMap:WaitForChild("Small_Buildings") for i,v in pairs(Large_Buildings:GetChildren()) do for a,k in pairs(v:GetChildren()) do if k:IsA("Part") or k:IsA("BasePart") then k.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then v:Destroy() end end) end end end for i,v in pairs(Small_Buildings:GetChildren()) do for a,k in pairs(v:GetChildren()) do if k:IsA("Part") or k:IsA("BasePart") then k.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then v:Destroy() end end) end end end