Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. function GetSpawnPoint(map,mapMaxHeight)
  2.     local outside,raypos,raydir;
  3.     local modelSize = map.Size;
  4.     local foundPoint;
  5.    
  6.     local vectorCheck;
  7.     print(mapMaxHeight)
  8.     while true do
  9.         wait()
  10.         --outside = map:GetModelCFrame() * CFrame.new(math.random(-modelSize.X/2,modelSize.X/2),-modelSize.Y,math.random(-modelSize.Z/2,modelSize.Z/2));
  11.         outside = map.CFrame * CFrame.new(math.random(-(modelSize.X/2),modelSize.X/2),mapMaxHeight,math.random(-(modelSize.Z/2),modelSize.Z/2));
  12.         raypos = outside.p;
  13.         raydir = ((outside.p - Vector3.new(0,-(mapMaxHeight*2),0)) - outside.p).unit * 9999;
  14.        
  15.         --[[local tBlock = Instance.new("Part", workspace); --Test to see where the ray origin is
  16.         tBlock.Anchored = true
  17.         tBlock.BrickColor = BrickColor.new("Bright green");
  18.         tBlock.Size = Vector3.new(10,10,10);
  19.         tBlock.CFrame = outside
  20.         debris:AddItem(tBlock,.5);]]
  21.        
  22.         local ray = NewRay(raypos, raydir);
  23.        
  24.         local hit,pos = workspace:FindPartOnRayWithIgnoreList(ray, characterFile:GetChildren());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement