So I've managed to make a BoolValue for the NPC, and I've made a script for the part, but the script isn't working. It either anchors the parts or unanchors the parts for both the player and NPC.

Here's the script I put in the parts:

x = game.workspace.NPC.Value
x.value = true
local debounce = false


function onHit(hit)
	local human = hit.Parent:findFirstChild("Humanoid")
	if (human ~= nil) and debounce == false then

           	 debounce = true
script.Parent.Anchored = false

           	 debounce = false
	else
		if x.value == false then
			script.Parent.Anchored = true
		end
	end
end

1 comment

0

Please refrain from posting duplicate questions.