I need to know how I can get my NPCs to see if they are touching the objective building in my game. I attempted a script that looks like this
Building = game.Workspace.BlueBuilding1 model = script.Parent model.PrimaryPart.Touched:Connect(function(hit) if hit.Parent.Name == "BlueBuilding1" then print("got it") Building.Strength = Building.Strength - 100 script.Parent.Humanoid.Health = 0 end end
but it doesn't seem to be working.
Small mistakes. You don't need primary part. This should do it:
Building = game.Workspace.BlueBuilding1 model = script.Parent model.Touched:Connect(function(hit) if hit.Parent.Name == "BlueBuilding1" then print("got it") Building.Strength = Building.Strength - 100 script.Parent.Humanoid.Health = 0 end end)
I didn't try this myself but it will probably work.