I was trying to make a script that would spawn npc to a random location when it dies. Can someone help me?
COMMUNITY QUESTION
Can you help me with this script?
1 answer
local model=script.Parent:Clone()
script.Parent.Humanoid.Died:connect(function()
wait(5)
m=model:Clone()
m.Parent=script.Parent.Parent
m:MoveTo(math.random(script.Parent:GetModelCFrame().p.X-50,script.Parent:GetModelCFrame().p.X+50)),1,math.random(script.Parent:GetModelCFrame().p.Z-50,script.Parent:GetModelCFrame().p.Z+50))
script.Parent:Destroy()
end)
I haven't tested this, but it should work.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Would it go in the npc ?
Yes.