Why isn't my Build System able to align the build able parts with the plot GridSize of 2??
Asked by
4 years ago Edited 4 years ago
My part of my script here is supposed to use a gridsize of 2 and it is oriented correctly but when you move the part it out aligns the part with the grid on the floor is there a way to make the part aligned with a vector?? or Cframe??? Please help if you can!
001 | local RunService = game:GetService( "RunService" ) |
002 | local UIS = game:GetService( "UserInputService" ) |
004 | local Player = game.Players.LocalPlayer |
005 | local Char = Player.Character or Player.CharacterAdded:Wait() |
006 | local Mouse = Player:GetMouse() |
007 | local Camera = workspace.CurrentCamera |
008 | local PlaceObject = game.ReplicatedStorage.BuildEvents.PlaceObject |
010 | local GivenPlot = game.ReplicatedStorage.BuildEvents.GivenPlot |
011 | local PlaceObject = game.ReplicatedStorage.BuildEvents.PlaceObject |
016 | local YPos = Vector 3. new( 0 , 75 , 0 ) |
022 | local ButtonObject = script.Parent.ScrollingFrame.Soil.ImageButton |
028 | GivenPlot.OnClientEvent:Connect( function (plt) |
030 | pltPX = plt.Position.X |
031 | pltPY = plt.Position.Y |
032 | pltPZ = plt.Position.Z |
033 | PlotO = plt.Orientation |
038 | local function Placement() |
039 | if IsPlacing and CanPlace then |
040 | PlaceObject:FireServer(posX, posY, posZ, Rot, Object.Name, PlotX, PlotY, PlotZ) |
049 | local function TopDownView() |
051 | local playerPos = Char:FindFirstChild( "HumanoidRootPart" ).Position |
052 | local cameraPos = playerPos + YPos |
054 | Camera.CFrame = CFrame.new(cameraPos, playerPos) |
057 | local function Movement() |
058 | if IsPlacing and CanPlace and not CanStart and Mouse.Target and Mouse.Target.Name = = Plot then |
059 | Mouse.TargetFilter = Object |
061 | posX = math.floor(Mouse.Hit.X / 2 + 0.5 )* 2 |
062 | posY = math.floor(Mouse.Hit.Y / 2 + 0.5 )* 2 - 1 |
063 | posZ = math.floor(Mouse.Hit.Z / 2 + 0.5 )* 2 |
064 | Object:SetPrimaryPartCFrame(Object.PrimaryPart.CFrame:Lerp(CFrame.new(posX, posY, posZ) * CFrame.Angles( 0 , math.rad(Rot), 0 ), 0.2 )) |
065 | Object.PrimaryPart.Orientation = (Vector 3. new(PlotX, PlotY, PlotZ)) |
071 | local function StartPlacementSoil() |
073 | Object = game:GetService( "ReplicatedStorage" ).Soil:Clone() |
074 | Object.Parent = workspace |
075 | Mouse.Move:Connect(Movement) |
080 | Mouse.Move:Connect(Movement) |
084 | local function StartPlacement(obj) |
086 | Object = game.ReplicatedStorage:FindFirstChild(obj):Clone() |
087 | Object.Parent = workspace |
095 | local function Rotation(input, GPE) |
096 | if IsPlacing and CanPlace and not CanStart and input.KeyCode = = Enum.KeyCode.R then |
099 | Object:SetPrimaryPartCFrame(Object.PrimaryPart.CFrame * CFrame.Angles( 0 , math.rad(Rot), 0 )) |
103 | Mouse.Button 1 Down:Connect(Placement) |
104 | ButtonObject.MouseButton 1 Click:Connect( function () |
105 | StartPlacement( "Soil" ) |
107 | RunService:BindToRenderStep( "Input" , Enum.RenderPriority.Input.Value, Movement) |
108 | UIS.InputBegan:Connect(Rotation) |