(Video made by my friend)
So the blocks keep floating and not going on the floor, and when I click to place a block and I click again, it isnt working. any help?
script:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local PosX
local PosY
local PosZ
local Model
local Button = script.Parent.TextButton
local GridSize = 2
local CanStart = true
local isPlacing = nil
local CanPlace = nil
local function Snap()
PosX = math.floor(Mouse.Hit.X / GridSize + 0.5) * GridSize
PosY = 3
PosY = math.floor(Mouse.Hit.Z / GridSize + 0.5) * GridSize
end
local function Placement()
if isPlacing and CanPlace then
local PlacedModel = Model:Clone()
PlacedModel.Parent = workspace.PlacedObjects
isPlacing = false
CanPlace = false
CanStart = true
end
end
local function Movement()
Mouse.TargetFilter = Model
Snap()
Model:SetPrimaryPartCFrame(CFrame.new(PosX, PosY, PosZ))
end
local function StartPlacementWoodBlock()
if CanStart then
Model = game:GetService("ReplicatedStorage").WoodBlock:Clone()
Model.Parent = workspace
isPlacing = true
CanPlace = true
CanStart = false
Mouse.Move:Connect(Movement)
end
end
Mouse.Button1Down:Connect(Placement)
Button.MouseButton1Click:Connect(StartPlacementWoodBlock)