Hey, I have a simple code for a placement system but if I wanted to add a grid how would I do that?
Here is my current code:
Written Form:
local player = game.Players.LocalPlayer
local RunService = game:GetService(“RunService”)
local UIS = game:GetService(“UserInputService”)
script.Parent.Enabled = true
for i,v in pairs(script.Parent.MainBuildFrame:GetChildren()) do
if v:IsA(“ImageButton”) then
v.MouseButton1Click:Connect(function()
local PreviewItem = game.ReplicatedStorage.Items:FindFirstChild(v.Name)
local RoatingObject = false
local RotationAmmount = 0
if PreviewItem then
local NewItem = PreviewItem:Clone()
NewItem.Parent = workspace
NewItem.Transparency = 0.5
NewItem.CanCollide = false
local Mouse = player:GetMouse()
UIS.InputBegan:Connect(function(Input, GameProccessed)
if Input.KeyCode == Enum.KeyCode.R then
if not GameProccessed then
RoatingObject = true
while RoatingObject == true do
task.wait()
RotationAmmount += 0.01
end
end
end
end)
UIS.InputEnded:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.R then
RoatingObject = false
end
end)
RunService.RenderStepped:Connect(function()
Mouse.TargetFilter = NewItem
NewItem.Position = Vector3.new(Mouse.Hit.Position.X, Mouse.Hit.Position.Y + NewItem.Size.Y / 2, Mouse.Hit.Position.Z)
if RoatingObject == true then
local ObjectAngles = CFrame.Angles(0,math.rad(RotationAmmount),0)
NewItem.CFrame = NewItem.CFrame * ObjectAngles
end
end)
end
end)
end
end