Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Zombies arent getting unanchored on part touch?

I was trying to create a script where when you touch a part the zombies would get unanchored. However, it didn't work. there were no red lines in the script. No errors were in the output menu So im not sure why its not working

The Code (Server Script)

local zombies = game.Workspace.MainMap.Stage1Z.SZ1:GetChildren()
local part = game.Workspace.MainMap.UnAnchors.Part

function ZombieAnchor()
	zombies.Anchored = false
end

part.Touched:Connect(ZombieAnchor)


Please Help its not working

2 answers

✓ Accepted answer

Try This:

script.Parent.Touched:Connect(function(hit)
   local human = hit.Parent:FindFirstChild("Humanoid")
    if (human ~= nil) then --Will detect only characters instead of parts ect
            zombies.Anchored = false
      end
end)

You cant just set multiple values to unanchored at once. You can use a loop to get all the parts and set them to unanchored individually.

local zombies = game.Workspace.MainMap.Stage1Z.SZ1:GetChildren()
local part = game.Workspace.MainMap.UnAnchors.Part

function ZombieAnchor()
	for i, v in ipairs(zombies) -- loop through all the parts
		if v:IsA("BasePart") then -- check if it is basepart so it can be anchored
			v.Anchored = false
		end
	end
end

part.Touched:Connect(ZombieAnchor)

This discussion is preserved as it was. New answers, comments, and votes are closed.