Advertisement
HCTGT_scripta

Placement System (wall handler)

Jan 14th, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. game.ReplicatedStorage.Events.PlaceWall.OnServerEvent:Connect(function(Player, Point1, Point2, Plot)
  2.     print(Point1, Point2)
  3.    
  4.     local Mag = (Point1 - Point2).magnitude
  5.    
  6.     local ray = Ray.new(Point1, (Point1 - Point2).unit * Mag)
  7.     local part, position = workspace:FindPartOnRay(ray, Player.Character)
  8.    
  9.     local Wall = Instance.new("Part", Plot.Objects.Walls)
  10.     Wall.Anchored = true
  11.     Wall.Transparency = 0
  12.     Wall.Name = "Wall"
  13.     Wall.TopSurface = Enum.SurfaceType.Smooth
  14.     Wall.BottomSurface = Enum.SurfaceType.Smooth
  15.    
  16.     local Distance = (Point1 - position).magnitude
  17.     Wall.Size = Vector3.new(.5, 10, math.floor(Mag)) + Vector3.new(0,0,.75)
  18.     Wall.CFrame = CFrame.new(Point1, position) * CFrame.new(0,0,Mag / 2)
  19. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement