ok so my align position takes a long time to be active idk why but it does that sometimes…
this is my code
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local RS = game:GetService("RunService")
local Target
local Equipped = false
local Mouseat = Instance.new("Attachment",workspace.Terrain)
local AP = game.Workspace.Terrain.AlignPosition
AP.Attachment1 = Mouseat
Mouseat.Visible = true
Mouseat.Name = "Mouse"
script.Parent.Equipped:Connect(function()
Equipped = true
end)
script.Parent.Unequipped:Connect(function()
Equipped = false
end)
local CenterAt = Instance.new("Attachment",script.Parent.Shoot)
local function setpos(SizeX,SizeY,SizeZ,Num)
local postable = {
Vector3.new(SizeX/3,SizeY/3,SizeZ/3),
Vector3.new(SizeX/3,-SizeY/3,SizeZ/3),
Vector3.new(-SizeX/3,SizeY/3,-SizeZ/3),
Vector3.new(-SizeX/3,-SizeY/3,-SizeZ/3)
}
return postable[Num]
end
Mouse.Button1Down:Connect(function()
if Mouse.Target and Mouse.Target:FindFirstChild("IsHoldAble") and Equipped == true then
Target = Mouse.Target
local partat = Instance.new("Attachment",Target)
AP.Attachment0 = partat
for i,v in pairs(game.Workspace.Beams:GetChildren()) do
v.Attachment1 = CenterAt
local at = Instance.new("Attachment",Target)
at.Position = setpos(Target.Size.X,Target.Size.Y,Target.Size.Z,i)
v.Attachment0 = at
end
end
end)
Mouse.Button1Up:Connect(function()
if Target ~= nil then
for i,v in pairs(Target:GetChildren()) do
if v:IsA("Attachment") then
v:Destroy()
end
end
end
end)
Mouse.Move:Connect(function()
local camera = game.Workspace.CurrentCamera
local pos = camera.CFrame.Position + (Mouse.Hit.Position - camera.CFrame.Position).Unit * 20
Mouseat.Position = pos
if Target ~= nil and Equipped == false then
for i,v in pairs(Target:GetChildren()) do
if v:IsA("Attachment") or v:IsA("AlignPosition") then
v:Destroy()
end
end
end
end)
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local RS = game:GetService("RunService")
local Target
local Equipped = false
local Mouseat = game.Workspace.Terrain.Mouse
local AP = game.Workspace.Terrain.AlignPosition
script.Parent.Equipped:Connect(function()
Equipped = true
end)
script.Parent.Unequipped:Connect(function()
Equipped = false
end)
local CenterAt = Instance.new("Attachment",script.Parent.Shoot)
local function setpos(SizeX,SizeY,SizeZ,Num)
local postable = {
Vector3.new(SizeX/3,SizeY/3,SizeZ/3),
Vector3.new(SizeX/3,-SizeY/3,SizeZ/3),
Vector3.new(-SizeX/3,SizeY/3,-SizeZ/3),
Vector3.new(-SizeX/3,-SizeY/3,-SizeZ/3)
}
return postable[Num]
end
Mouse.Button1Down:Connect(function()
if Mouse.Target and Mouse.Target:FindFirstChild("IsHoldAble") and Equipped == true then
Target = Mouse.Target
local partat = Instance.new("Attachment")
partat.Parent = Target
AP.Attachment0 = partat
for i,v in pairs(game.Workspace.Beams:GetChildren()) do
v.Attachment1 = CenterAt
local at = Instance.new("Attachment",Target)
at.Position = setpos(Target.Size.X,Target.Size.Y,Target.Size.Z,i)
v.Attachment0 = at
end
end
end)
Mouse.Button1Up:Connect(function()
if Target ~= nil then
for i,v in pairs(Target:GetChildren()) do
if v:IsA("Attachment") then
v:Destroy()
end
end
end
end)
Mouse.Move:Connect(function()
local camera = game.Workspace.CurrentCamera
local pos = camera.CFrame.Position + (Mouse.Hit.Position - camera.CFrame.Position).Unit * 20
Mouseat.Position = pos
if Target ~= nil and Equipped == false then
for i,v in pairs(Target:GetChildren()) do
if v:IsA("Attachment") or v:IsA("AlignPosition") then
v:Destroy()
end
end
end
end)