I tried using math.random(), but i got a error message, here's the code I used:
local CTorso = Clone:FindFirstChild("UpperTorso") or Clone:FindFirstChild("Torso")
if Map:FindFirstChild("Min") and Map:FindFirstChild("Max") then
local Min = Map:FindFirstChild("Min")
local Max =Map:FindFirstChild("Max")
CTorso.CFrame = CFrame.new(math.random(Max.Position.X,Min.Position.X), math.random(Max.Position.Y,Min.Position.Y)+5,math.random(Max.Position.Z,Min.Position.Z))
else
error("Min/Max Is Missing From Map")
break
end

4 comments
I forgot to mention that it works perfectly in studio
Where is the NPC located? I reccomend ReplicatedStorage or ServerStorage
Also, do you want the NPC to spawn in a random location or just 1 location?
@zboi i want the npc to spawn in a random location with a certain set of coords represented with two parts, min and max. the distance between those two parts represents the possibilities