You can write your topic however you want, but you need to answer these questions:
-
I want to make a Grid Build System for players to place items on their plot which makes it save for when they come back
-
I’ve tried a few attempts with it and they don’t really work the way I would like them to. They either don’t move in a Grid Formation or keep their orientation aligned with the orientation of the plot. i really need someone to tell me what resources to use or how to RayCast.
-
Here’s my attempt at the system:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Camera = game.Workspace.CurrentCamera
local BuildPro = false
local OnPlot = false
local BuildUi = script.Parent.FHOS.Frame.BuildFrame
local MarketPlaceService = game:GetService("MarketplaceService")
local RunService = game:GetService("RunService")
game.Players.PlayerAdded:Connect(function()
local hasPass = false
local success, message = pcall(function()
hasPass = MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, 11321181)
end)
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true then
BuildPro = true
end
end)
local UIS = game:GetService("UserInputService")
local Grid = 2
local Rot = 0
local PosX
local PosY
local PosZ
local Plot
local PlotO
local PlotX
local PlotY
local PlotZ
local Object
local GivenPlot = game.ReplicatedStorage.BuildEvents.GivenPlot
local PlaceObject = game.ReplicatedStorage.BuildEvents.PlaceObject
GivenPlot.OnClientEvent:Connect(function(plt)
Plot = plt
PlotO = plt.Orientation
PlotX = PlotO.X
PlotY = PlotO.Y
PlotZ = PlotO.Z
end)
Plot.Touched:Connect(function(hit)
local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if plr then
OnPlot = true
end
end)
local CanStart = true
local Placing = nil
local CanPlace = nil
local MoveObject = false
local CanPlace
local BuildMode = Instance.new("BoolValue")
BuildMode.Parent = Player
BuildMode = false
BuildSelection = BuildUi.ScrollingFrame
Soil = BuildSelection.SoilSelect.ImageButton
script.Parent.FHOS.Frame.Frame.BuildModeApp.TextButton.MouseButton1Click:Connect(function()
script.Parent.FHOS.Frame.Frame.Visible = false
script.Parent.FHOS.Frame.FhBrand.Visible = false
script.Parent.FHOS.Frame.Power.Visible = false
script.Parent.FHOS.Frame.Time.Visible = false
script.Parent.FHOS.Frame.Network.Visible = false
script.Parent.FHOS.Frame.Battery.Visible = false
script.Parent.FHOS:TweenPosition(UDim2.new(0.105, 0,0.485, 0), "Out", "Linear", 1, false, nil)
while script.Parent.FHOS.Rotation > -90 do
script.Parent.FHOS.Rotation = script.Parent.FHOS.Rotation - 1
wait()
end
BuildMode = true
if BuildMode == true and OnPlot == true or BuildPro == true then
Camera.CameraSubject = Plot
end
end)
local function SnapToGrid()
PosX, PosY, PosZ = math.floor(Mouse.Hit.X / Grid + .5) * Grid, math.floor(Mouse.Hit.Y / Grid + 1) * Grid, math.floor(Mouse.Hit.Z / Grid + .5) * Grid
end
local function MouseMoved()
Object.PrimaryPart.Position = Vector3.new(PosX, PosY, PosZ)
SnapToGrid()
end
local function CloneService(Obj)
Object = game.ReplicatedStorage.BuildObjects:FindFirstChild(Obj):Clone()
Object.Parent = Plot
Object.PrimaryPart.Orientation = Vector3.new(PlotX, PlotY, PlotZ)
Mouse.Move:Connect(MouseMoved)
end
Soil.MouseButton1Click:Connect(function()
CloneService("Soil")
end)
Please give me some tips or suggestions of how to make my build system make parts stay aligned with the plot if the plot isn’t in a whole number orientation and how to save so the player rejoins can continue their plot. Hope someone has a suggestion because I’ve been researching all summer.