Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone help me with teleporting NPCs to a map?

Asked by
Z9R 5
5 years ago

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

here's the error message I got Can anyone help me?

0
I forgot to mention that it works perfectly in studio Z9R 5 — 5y
0
Where is the NPC located? I reccomend ReplicatedStorage or ServerStorage User#25920 0 — 5y
0
Also, do you want the NPC to spawn in a random location or just 1 location? User#25920 0 — 5y
0
@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 Z9R 5 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago

Add this to the top of your script.


Max = 150.Studs.Length Min = 25.Studs.Length local CTorso = Clone:FindFirstChild("UpperTorso")
0
**smacks head really hard** u cant just do that 1st its to short and 2nd u didn't explain why. WideSteal321 773 — 5y
Ad

Answer this question