Part spawns ai when touched

I would like to know how to make a part spawn a guy when you step on it

You can use a Touched event that when triggered it will spawn in the NPC.

local serverStorage = game:GetService("ServerStorage")
local players = game:GetService("Players")

local part = script.Parent -- Location of your part

part.Touched:Connect(function(otherPart)
    local player = players:GetPlayerFromCharacter(otherPart.Parent)

    if player then -- Checks if the object that touched this part is a player
       local NPC = serverStorage.NPC:Clone()
       NPC.Parent = workspace -- Spawns the NPC into the game
    end
end)
1 Like

do i add the script to the part?

Yes you can.

You can also put it in ServerScriptService just don’t forget to reference the parts location properly.