client script:
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local Mouse = game.Players.LocalPlayer:GetMouse()
local RSe = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local event = RSe.Events:WaitForChild("PlacementEvent")
local event2 = RSe.Events:WaitForChild("Move")
local event3 = RSe.Events:WaitForChild("Stop")
local eventdelete = RSe.Events:WaitForChild("NoN")
local eventdestroy = RSe.Events:WaitForChild("No")
local eventstart = RSe.Events:WaitForChild("Yes")
local event4 = RSe.Events:WaitForChild("Place!")
local event5 = RSe.Events:WaitForChild("MOOVE")
local PosX
local PosY
local PosZ
local Rot = 0
local mouseTarget = Mouse.Target.Name
local Button = game.Players.LocalPlayer.PlayerGui.ScreenGui.MainGui.GSOoneblockbut
local GridSize = 2
local Fil = script.Parent.Parent.Parent.Filters
local Fact = script.Parent.Parent.Parent.Factions
local But = script.Parent.Parent.Parent.Buttus
local scroll2 = script.Parent.Parent.Parent.MainGui_12
local scroll = script.Parent.Parent.Parent.MainGui
local Keyz = script.Parent.Parent.Parent.Keyz
local Keyzz = script.Parent.Parent.Parent.Keyzz
local Keyzzz = script.Parent.Parent.Parent.Keyzzz
local CanStart = true
local IsPlacing = false
local CanPlace = false
local taable = nil
--------------------------------Functions-----------------------------------------------------------------------------
local function Snap()
PosX = math.floor(Mouse.Hit.Position.X)
PosY = math.floor(Mouse.Hit.Position.Y)
PosZ = math.floor(Mouse.Hit.Position.Z)
end
local function Movement()
if IsPlacing and CanPlace and Mouse.Target.Name == "Grid" or not Mouse.Target.Name == "Terrain" and not CanStart then
event5:FireServer(Mouse.Target)
event3:FireServer()
Mouse.TargetFilter = workspace:FindFirstChild("GSOoneblock")
elseif IsPlacing and CanPlace and Mouse.Target.Name == "Terrain" --[[or Mouse.Target:IsA("Part")]] or Mouse.Target:IsA("VehicleSeat") and not CanStart then
Snap()
event2:FireServer(PosX,PosY,PosZ)
event3:FireServer()
Mouse.TargetFilter = workspace:FindFirstChild("GSOoneblock")
else
return Mouse.Hit.p
end
end
local function StartPlacementCrate()
if CanStart then
scroll:TweenPosition(UDim2.new(-0.830, 0,0.221, 0),"Out","Quad",0.4)
scroll2:TweenPosition(UDim2.new(-0.590,0,0.539,0),"Out","Quad",0.4)
Fact:TweenPosition(UDim2.new(-1, 0,0.221,0),"Out","Quad",0.4)
Fil:TweenPosition(UDim2.new(-1,0,0.221, 0),"Out","Quad",0.4)
But:TweenPosition(UDim2.new(-1,0,0.13,0),"Out","Quad",0.4)
Keyz:TweenPosition(UDim2.new(0.426, 0,0.773, 0),"Out","Quad",0.4)
Keyzz:TweenPosition(UDim2.new(0.277, 0,0.787, 0),"Out","Quad",0.4)
Keyzzz:TweenPosition(UDim2.new(0.567, 0,0.787, 0),"Out","Quad",0.4)
script.Parent:TweenPosition(UDim2.new(0.211, 0,0.180, 0),"Out","Quad",0)
wait()
script.Parent:Clone().Parent = Keyz
IsPlacing = true
CanPlace = true
CanStart = false
eventstart:FireServer()
Mouse.Move:Connect(Movement)
UIS.InputBegan:Connect(Movement)
UIS.InputChanged:Connect(Movement)
UIS.InputEnded:Connect(Movement)
RS.Heartbeat:Connect(Movement)
RS.Changed:Connect(Movement)
Mouse.Button1Down:Connect(Movement)
end
end
local function StopPlacement(input)
if input.KeyCode == Enum.KeyCode.X and IsPlacing and CanPlace and not CanStart then
Keyz:TweenPosition(UDim2.new(0.426, 0,1, 0),"Out","Quad",0.4)
Keyzz:TweenPosition(UDim2.new(0.277, 0,1, 0),"Out","Quad",0.4)
Keyzzz:TweenPosition(UDim2.new(0.567, 0,1, 0),"Out","Quad",0.4)
IsPlacing = false
CanPlace = false
CanStart = true
eventdestroy:FireServer()
wait(0.5)
Keyz:ClearAllChildren()
end
end
local function LowBlocks()
if game.ReplicatedStorage.Values.GSOoneblock.Value <= 0 then
local yeetele = Player.PlayerGui.ScreenGui.MainGui
Keyz:TweenPosition(UDim2.new(0.426, 0,1, 0),"Out","Quad",0.4)
Keyzz:TweenPosition(UDim2.new(0.277, 0,1, 0),"Out","Quad",0.4)
Keyzzz:TweenPosition(UDim2.new(0.567, 0,1, 0),"Out","Quad",0.4)
IsPlacing = false
CanPlace = false
CanStart = true
eventdelete:FireServer()
yeetele.GSOoneblockbut.Visible = false
else
local yeetele = Player.PlayerGui.ScreenGui.MainGui
yeetele.GSOoneblockbut.Visible = true
end
end
local function Placement()
if IsPlacing and CanPlace and Mouse.Target.Name == "Terrain" or not Mouse.Target.Name == "Grid" and not CanStart and game.ReplicatedStorage.Values.GSOoneblock.Value > 0 then
Snap()
event:FireServer()
end
end
local function Placement2()
if IsPlacing and CanPlace and Mouse.Target.Name == "Grid" and not CanStart then
Snap()
event4:FireServer(Mouse.Target)
end
end
while IsPlacing do
Snap()
event2:FireServer(PosX,PosY,PosZ)
end
Mouse.Button1Down:Connect(Placement)
Mouse.Button1Down:Connect(Placement2)
Button.MouseButton1Click:Connect(StartPlacementCrate)
UIS.InputBegan:Connect(StopPlacement)
UIS.InputBegan:Connect(LowBlocks)
UIS.InputEnded:Connect(StopPlacement)
UIS.InputEnded:Connect(LowBlocks)
RS.Heartbeat:Connect(LowBlocks)
server script:
-- // Variables
local RS = game:GetService("ReplicatedStorage")
local event = RS.Events:WaitForChild("PlacementEvent")
local Model
local event2 = RS.Events:WaitForChild("Move")
local event3 = RS.Events:WaitForChild("Stop")
local eventsdelete = RS.Events:WaitForChild("NoN")
local eventdestroy = RS.Events:WaitForChild("No")
local eventstart = RS.Events:WaitForChild("Yes")
local event4 = RS.Events:WaitForChild("Place!")
local event5 = RS.Events:WaitForChild("MOOVE")
local taable = true
local taabel = {}
-- // Main
event2.OnServerEvent:Connect(function(plr,PosX,PosY,PosZ)
Model.Parent = workspace
Model.GSOoneblock.CanCollide = false
Model:SetPrimaryPartCFrame(CFrame.new(PosX,PosY+5,PosZ))
end)
event5.OnServerEvent:Connect(function(plr,mouseTarget)
local off = CFrame.new(0,0,2)
Model.Parent = workspace
Model.GSOoneblock.CanCollide = false
Model.GSOoneblock.CFrame = mouseTarget.CFrame:ToWorldSpace(off)
end)
event3.OnServerEvent:Connect(function(plr)
local collision = Model.PrimaryPart.Touched:Connect(function() end)
local collisionPoints = Model.PrimaryPart:GetTouchingParts()
for i = #collisionPoints, #collisionPoints do
if not collisionPoints[i]:IsDescendantOf(workspace.Folder) then
taable = true
Model.GSOoneblock.SelectionBox.SurfaceTransparency = 1
Model.GSOoneblock.SelectionBox.Color3 = Color3.fromRGB(255,255,255)
elseif collisionPoints[i]:IsDescendantOf(workspace.Folder) then
taable = false
Model.GSOoneblock.SelectionBox.Color3 = Color3.fromRGB(208,37,37)
Model.GSOoneblock.SelectionBox.SurfaceTransparency = 0.8
end
end
end)
event.OnServerEvent:Connect(function(plr)
if taable == true then
local PlacedModel = Model:Clone()
game.ReplicatedStorage.Values.GSOoneblock.Value = game.ReplicatedStorage.Values.GSOoneblock.Value -1
PlacedModel.GSOoneblock.CanCollide = true
PlacedModel.GSOoneblock.Anchored = false
PlacedModel.GSOoneblock.SelectionBox.Visible = false
PlacedModel.Parent = workspace.PlacedObjects
end
end)
eventdestroy.OnServerEvent:Connect(function(plr)
Model:Destroy()
wait()
Model = nil
end)
eventsdelete.OnServerEvent:Connect(function(plr)
Model:Destroy()
wait()
Model = nil
end)
eventstart.OnServerEvent:Connect(function(plr)
Model = game:GetService("ReplicatedStorage").GSOoneblock:Clone()
Model.GSOoneblock.CanCollide = false
end)
event4.OnServerEvent:Connect(function(plr,mouseTarget)
if taable == true then
local PlacedModel = Model:Clone()
game.ReplicatedStorage.Values.GSOoneblock.Value = game.ReplicatedStorage.Values.GSOoneblock.Value -1
local weld = Instance.new("WeldConstraint")
PlacedModel.GSOoneblock.CanCollide = true
PlacedModel.GSOoneblock.Anchored = false
PlacedModel.GSOoneblock.SelectionBox.Visible = false
weld.Parent = PlacedModel
weld.Part0 = PlacedModel.GSOoneblock
weld.Part1 = mouseTarget
PlacedModel.Parent = workspace.PlacedObjects
end
end)
while wait() do
workspace:GetChildren(taabel)
if table.find(taabel,"GSOoneblock",2) then
Model:Destroy()
end
end
sorry for not putting it in