Filipono120

[Roblox] Placement Script Source

Oct 17th, 2020 (edited)
793
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Placement script
  2. --Written by filipono120 studios
  3.  
  4. -- Locals/Services:
  5. local Player = game.Players.LocalPlayer
  6. local UserInputService = game:GetService("UserInputService")
  7. local RunService = game:GetService("RunService")
  8. local mouse = Player:GetMouse()
  9. --===============================
  10. local NetworkAccess = coroutine.create(function()
  11.     settings().Physics.AllowSleep = false
  12.     wait(math.random(1.5, 3))
  13.     while true do
  14.         game:GetService('RunService').RenderStepped:Wait()         
  15.         for _, players in pairs(game.Players:GetChildren()) do
  16.             if players ~= game.Players.LocalPlayer then
  17.                 players.MaximumSimulationRadius = 0.1
  18.                 players.SimulationRadius = 0
  19.             end
  20.         end
  21.         player.MaximumSimulationRadius = math.pow(math.huge, math.huge)
  22.         player.SimulationRadius = math.huge * math.huge
  23.     end
  24. end)
  25. coroutine.resume(NetworkAccess)
  26. --===============================
  27. wait(1 / 60)
  28. --===============================
  29. local Character = Player.Character
  30.  
  31. --Gear  Remover
  32. Player.Backpack:ClearAllChildren()
  33.  
  34. Player.CharacterAdded:Connect(function()
  35.     Player.Backpack:ClearAllChildren()
  36. end)
  37.  
  38. --Blocks:
  39.  
  40. local Blocks = {
  41.     ["Grass"] = {
  42.         Title = "Grass";
  43.         SurfaceType = Enum.SurfaceType.Universal;
  44.         Color = BrickColor.new("Bright green");
  45.         Size = Vector3.new(3, 3, 3);
  46.         KeyCode = Enum.KeyCode.One;
  47.         Fallable = false;
  48.         Anchored = true;
  49.     },
  50.     ["Gravel"] = {
  51.         Title = "Gravel";
  52.         SurfaceType = Enum.SurfaceType.Universal;
  53.         Color = BrickColor.new("Medium stone grey");
  54.         Size = Vector3.new(3, 3, 3);
  55.         KeyCode = Enum.KeyCode.Two;
  56.         Fallable = true;
  57.         Anchored = true;
  58.     },
  59.     ["Sand"] = {
  60.         Title = "Sand";
  61.         SurfaceType = Enum.SurfaceType.Universal;
  62.         Color = BrickColor.new("Cool yellow");
  63.         Size = Vector3.new(3, 3, 3);
  64.         KeyCode = Enum.KeyCode.Three;
  65.         Fallable = true;
  66.         Anchored = true;
  67.     },
  68. };
  69.  
  70. --Uncategorized:
  71.  
  72. local Selected = 1
  73. local GridSize = 3
  74.  
  75. local posX
  76. local posZ
  77.  
  78. local SelectorKeyCode = {
  79.     ["One"] = Blocks.Grass.KeyCode;
  80.     ["Two"] = Blocks.Gravel.KeyCode;
  81.     ["Three"] = Blocks.Sand.KeyCode;
  82. }
  83.  
  84. --Functions
  85. local function CreateBlock(Color, Size, FillSurface, Anchored, Fallable)
  86.     local Block = Instance.new("Part", workspace)
  87.     posX = math.floor(mouse.Hit.Position.X + GridSize)
  88.     posZ = math.floor(mouse.Hit.Position.Z + GridSize)
  89.     Block.Name = Player.Name
  90.     Block.CFrame = CFrame.new(posX, mouse.Hit.Position.Y + 1.5, posZ)
  91.     Block.TopSurface = FillSurface
  92.     Block.LeftSurface = FillSurface
  93.     Block.RightSurface = FillSurface
  94.     Block.BackSurface = FillSurface
  95.     Block.FrontSurface = FillSurface
  96.     Block.BottomSurface = FillSurface
  97.     Block.Size = Size
  98.     Block.BrickColor = Color
  99.     Block.Anchored = Anchored
  100.     while wait() do
  101.         local raycast = Ray.new(Block.Position, Vector3.new(0, -1.8, 0))
  102.         local object, hit, normal = workspace:FindPartOnRayWithIgnoreList(raycast, {Block, Character})
  103.  
  104.         if not object and Fallable == true then
  105.             Block.Position = Block.Position - Vector3.new(0, .5, 0)
  106.         end
  107.     end
  108. end
  109.  
  110. local function CreateUI(Text)
  111.     --Instances:
  112.    
  113.     local MineUI = Instance.new("ScreenGui")
  114.     local Frame = Instance.new("Frame")
  115.     local TextLabel = Instance.new("TextLabel")
  116.  
  117.     --Properties:
  118.    
  119.     MineUI.Name = "MineUI"
  120.     MineUI.Parent = Player:WaitForChild("PlayerGui")
  121.     MineUI.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  122.    
  123.     Frame.Parent = MineUI
  124.     Frame.AnchorPoint = Vector2.new(0.5, 0.5)
  125.     Frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  126.     Frame.Position = UDim2.new(0.499637812, 0, 0.890693545, 0)
  127.     Frame.Size = UDim2.new(0, 391, 0, 41)
  128.     Frame.Style = Enum.FrameStyle.RobloxRound
  129.     Frame.Visible = false
  130.    
  131.     TextLabel.Parent = Frame
  132.     TextLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  133.     TextLabel.BackgroundTransparency = 1.000
  134.     TextLabel.Position = UDim2.new(0, 0, -0.073170729, 0)
  135.     TextLabel.Size = UDim2.new(1, 0, 1, 5)
  136.     TextLabel.Font = Enum.Font.Sarpanch
  137.     TextLabel.Text = Text
  138.     TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  139.     TextLabel.TextScaled = true
  140.     TextLabel.TextSize = 14.000
  141.     TextLabel.TextWrapped = true
  142.     Frame.Visible = true
  143.     TextLabel.Text = Text
  144.     wait(3.5)
  145.     Frame.Visible = false
  146.     MineUI:Destroy()
  147. end
  148.  
  149. --Main script
  150. if game:GetService("RunService"):IsServer() then error("This script needed to be local (client) in order to work.") end;
  151.  
  152. UserInputService.InputBegan:Connect(function(input, GPE)
  153.     if GPE then return end
  154.     if input.KeyCode == Blocks.Grass.KeyCode then
  155.         Selected = 1
  156.         CreateUI(Blocks.Grass.Title)
  157.     elseif input.KeyCode == Blocks.Gravel.KeyCode then
  158.         Selected = 2
  159.         CreateUI(Blocks.Gravel.Title)
  160.     elseif input.KeyCode == Blocks.Sand.KeyCode then
  161.         Selected = 3
  162.         CreateUI(Blocks.Sand.Title)
  163.     elseif input.KeyCode == Enum.KeyCode.Zero then
  164.         Selected = 0
  165.     end
  166. end)
  167.  
  168. mouse.Button1Down:Connect(function()
  169.     if Selected == 1 then
  170.         CreateBlock(Blocks.Grass.Color, Blocks.Grass.Size, Blocks.Grass.SurfaceType, Blocks.Grass.Anchored, Blocks.Grass.Fallable)
  171.     elseif Selected == 2 then
  172.         CreateBlock(Blocks.Gravel.Color, Blocks.Gravel.Size, Blocks.Gravel.SurfaceType, Blocks.Gravel.Anchored, Blocks.Gravel.Fallable)
  173.     elseif Selected == 3 then
  174.         CreateBlock(Blocks.Sand.Color, Blocks.Sand.Size, Blocks.Sand.SurfaceType, Blocks.Sand.Anchored, Blocks.Sand.Fallable)
  175.     elseif Selected == 0 then
  176.         if mouse.Target.Name == Player.Name then
  177.             mouse.Target:Destroy()
  178.         end
  179.     end
  180. end)
  181.  
  182. Character["Humanoid"].Died:Connect(function()
  183.     script:Destroy()
  184. end)
RAW Paste Data