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

How Do I Make The NPC Not go Through The Part But Players can Go In???

Hello, I'm Making A Simulator Game And I'm Making This Script But The NPC Keeps Coming out Cause I Need To Put It On Cancollide Off So Can Anyone make 10 Model named "Zombie" And The Zombies Can't Come Out, Thanks!

local Players = game:GetService("Players")
local sword = game.ReplicatedFirst.ClassicSword
local debounce = false

local part = script.Parent
local function onTouched(part)  
    if not debounce then
        debounce = true
        local player = Players:GetPlayerFromCharacter(part.Parent)
        if not player then return end
        local backpack = player.Backpack
        sword:Clone().Parent = backpack
        delay(5, function()
            debounce = false
        end)
    end
end
part.Touched:Connect(onTouched)

1 answer

Make the script a localscript instead. Or instead you can try learning about CollisionGroups

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