вот весь скрипт!
-- Settings --
-- Bools --
local Interpolation = true
local MoveByGrid = true
local BuildModePlacement = true
-- Ints --
local RotationStep = 90
local MaxHeight = 90
-- Number/Floats --
local LerpLevel = 0.7 -- 0 = instant snapping, 1 = no movement at all --
-- Other --
local GridTexture = ""
local Placement = {}
Placement.__index = Placement
local Players = game:GetService("Players")
local RunS = game:GetService("RunService")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()
-- Constructor Variables --
local GRID_SIZE
local ITEM_LOCATION
local ROTATE_KEY
local TERMINATE_KEY
-- Activation Variable --
local Object
local PlacedObjects
local Plot
local Stackable
-- Variables used in calculation --
local posX
local posY
local posZ
local speed = 1
-- Calculates the initial y position above an object --
local function CalculateYPosition()
end
local function Snap(X)
return math.round(X / GRID_SIZE) * GRID_SIZE
end
-- Calculates the items position based on grid --
local function CalculateItemPosition()
if MoveByGrid then
posX = Snap(Mouse.Hit.X)
posY = 3
posZ = Snap(Mouse.Hit.Z)
else
posX = Mouse.Hit.X
posY = Mouse.Hit.Y
posZ = Mouse.Hit.Z
end
end
-- Sets Model position based on pivot --
local function TranslateObj()
if PlacedObjects and Object.Parent == PlacedObjects then
CalculateItemPosition()
Object:PivotTo(Object.PrimaryPart.CFrame:Lerp(CFrame.new(posX, posY, posZ), speed))
end
end
local function ApprovePlacement()
return true
end
-- Constructor Function --
function Placement.new(Grid_Size, Objects, Rotate_Key, Term_Key)
local Data = {}
local MetaData = setmetatable(Data, Placement)
GRID_SIZE = Grid_Size
ITEM_LOCATION = Objects
ROTATE_KEY = Rotate_Key
TERMINATE_KEY = Term_Key
Data.grid = GRID_SIZE
Data.itemlocation = ITEM_LOCATION
Data.rotatekey = ROTATE_KEY
Data.terminatekey = TERMINATE_KEY
return Data
end
-- Activate Placement --
function Placement:Activate(Id, PLObjects, Plt, Stk)
-- Assigns values for necessary variables --
Object = ITEM_LOCATION:FindFirstChild(Id):Clone()
--Object.Material = Enum.Material.ForceField
--Object.CanCollide = false
PlacedObjects = PLObjects
Plot = Plt
Stackable = Stk
-- Make sure placement can activate properly --
if not ApprovePlacement() then
return "Placement could not activate"
end
-- Filters objects from mouse depending on stackable variable
if not Stackable then
Mouse.TargetFilter = PlacedObjects
else
Mouse.TargetFilter = Object
end
-- Место где ошибка --
-- Sets up interpolation speed --
local preSpeed = 1
if Interpolation then
preSpeed = 0.3
speed = preSpeed
end
-- --
Object.Parent = PlacedObjects
end
RunS:BindToRenderStep("Input", Enum.RenderPriority.Input.Value, TranslateObj)
return Placement
-- Settings --
-- Bools --
local Interpolation = true
local MoveByGrid = true
local BuildModePlacement = true
-- Ints --
local RotationStep = 90
local MaxHeight = 90
-- Number/Floats --
local LerpLevel = 0.7 -- 0 = instant snapping, 1 = no movement at all --
-- Other --
local GridTexture = ""
local Placement = {}
Placement.__index = Placement
local Players = game:GetService("Players")
local RunS = game:GetService("RunService")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()
-- Constructor Variables --
local GRID_SIZE
local ITEM_LOCATION
local ROTATE_KEY
local TERMINATE_KEY
-- Activation Variable --
local Object
local PlacedObjects
local Plot
local Stackable
-- Variables used in calculation --
local posX
local posY
local posZ
local speed = 1
-- Calculates the initial y position above an object --
local function CalculateYPosition()
end
local function Snap(X)
return math.round(X / GRID_SIZE) * GRID_SIZE
end
-- Calculates the items position based on grid --
local function CalculateItemPosition()
if MoveByGrid then
posX = Snap(Mouse.Hit.X)
posY = 3
posZ = Snap(Mouse.Hit.Z)
else
posX = Mouse.Hit.X
posY = Mouse.Hit.Y
posZ = Mouse.Hit.Z
end
end
-- Sets Model position based on pivot --
local function TranslateObj()
if PlacedObjects and Object.Parent == PlacedObjects then
CalculateItemPosition()
Object:PivotTo(Object.PrimaryPart.CFrame:Lerp(CFrame.new(posX, posY, posZ), speed))
end
end
local function ApprovePlacement()
return true
end
-- Constructor Function --
function Placement.new(Grid_Size, Objects, Rotate_Key, Term_Key)
local Data = {}
local MetaData = setmetatable(Data, Placement)
GRID_SIZE = Grid_Size
ITEM_LOCATION = Objects
ROTATE_KEY = Rotate_Key
TERMINATE_KEY = Term_Key
Data.grid = GRID_SIZE
Data.itemlocation = ITEM_LOCATION
Data.rotatekey = ROTATE_KEY
Data.terminatekey = TERMINATE_KEY
return Data
end
-- Activate Placement --
function Placement:Activate(Id, PLObjects, Plt, Stk)
-- Assigns values for necessary variables --
Object = ITEM_LOCATION:FindFirstChild(Id):Clone()
--Object.Material = Enum.Material.ForceField
--Object.CanCollide = false
PlacedObjects = PLObjects
Plot = Plt
Stackable = Stk
-- Make sure placement can activate properly --
if not ApprovePlacement() then
return "Placement could not activate"
end
-- Filters objects from mouse depending on stackable variable
if not Stackable then
Mouse.TargetFilter = PlacedObjects
else
Mouse.TargetFilter = Object
end
-- Место где ошибка --
-- Sets up interpolation speed --
local preSpeed = 1
if Interpolation then
preSpeed = 0.3
speed = preSpeed
end
-- --
Object.Parent = PlacedObjects
end
RunS:BindToRenderStep("Input", Enum.RenderPriority.Input.Value, TranslateObj)
return Placement