Advertisement
HowToRoblox

BuildingServer

Feb 13th, 2023
1,534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. local structures = game.ReplicatedStorage:WaitForChild("Structures")
  2. local remote = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("PlaceStructure")
  3.  
  4. local modules = game.ServerStorage:WaitForChild("ModuleScripts")
  5. local findClosestStructure = require(modules:WaitForChild("FindClosestStructure"))
  6. local placeStructure = require(modules:WaitForChild("PlaceStructure"))
  7.  
  8.  
  9. local structuresContainer = Instance.new("Folder")
  10. structuresContainer.Name = "STRUCTURES"
  11. structuresContainer.Parent = workspace
  12.  
  13.  
  14. remote.OnServerEvent:Connect(function(plr, structure, pos, rot)
  15.    
  16.     if plr and plr.Character and plr.Character:FindFirstChild("Humanoid") and plr.Character.Humanoid.Health > 0 then
  17.        
  18.         if structure and structure.Parent == structures then
  19.             if pos and typeof(pos) == "Vector3" and typeof(rot) == "number" then
  20.                
  21.                 local closestStructureCF = findClosestStructure(structure, pos, rot)
  22.                
  23.                 if closestStructureCF then
  24.                     placeStructure(plr, structure, closestStructureCF)
  25.                 end
  26.             end
  27.         end
  28.     end
  29. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement