Hello! I wanted to make a script where a NPC approaches this gate and then once touched it, the NPC will start dealing some damage to it. Damage represented by a IntValue. I used a RemoteEvent.
--LOCAL SCRIPT PUT IN THE GATE (PART PUT IN WORKSPACE)
script.Parent.Touched:Connect(function(db)
local hum = db.Parent:WaitForChild("Humanoid")
if hum then
game.ReplicatedStorage.GATE:FireServer()
end
end)
--SCRIPT PUT IN THE NPC
local zombie = script.Parent
local humanoid = zombie.Humanoid
local pointA = game.Workspace.DGATE.Humanoid
humanoid:MoveTo(pointA.Position)
game.ReplicatedStorage.GATE.OnServerEvent:Connect(function()
print("Received")
while wait(3) do
pointA.Health:Damage(15)
end
end)
Please help!
EDIT. I tried modifying some things. It is not working at all. It like doesn't notice I touch the part. I tried inserting a "print" after the Touched event. No signs. Why?

3 comments
why would you have local script in gate?
@karlo_tr10 Because I couldn't do the "FireServer".
I think you should put your gate script into normal script(server script)