(sorry for video lag)
the video above shows the error
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local RS = game:GetService("RunService")
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local headat = Instance.new("Attachment",script.Parent.Shoot)
local function setpos(SizeX,SizeY,Num)
local postable = {
Vector3.new(0,SizeY/3,SizeX/3),
Vector3.new(0,-SizeY/3,SizeX/3),
Vector3.new(0,SizeY/3,-SizeX/3),
Vector3.new(0,-SizeY/3,-SizeX/3)
}
return postable[Num]
end
Mouse.Button1Down:Connect(function()
Target = Mouse.Target
if Target~= nil and Target:IsA("Part") and Target.Anchored == false then
script.Box.Adornee = Target
for i,v in pairs(game.Workspace.Beams:GetChildren()) do
local at = Instance.new("Attachment",Target)
at.Position = setpos(Target.Size.X,Target.Size.Y,i)
v.Attachment1 = at
v.Attachment0 = headat
end
end
end)
local tweenservs = game:GetService("TweenService")
local info = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local info1 = TweenInfo.new(0.1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
RS.RenderStepped:Connect(function()
for i,v in pairs(game.Workspace.Beams:GetChildren()) do
local CT0 = tweenservs:Create(v,info1,{CurveSize0 = math.random(-10,10)})
local CT1 = tweenservs:Create(v,info1,{CurveSize1 = math.random(-10,10)})
CT0:Play()
CT1:Play()
end
if Target~= nil and script.Box.Adornee ~= nil and Target.Anchored == false then
CFRAME = script.Parent.Shoot.CFrame
tween = tweenservs:Create(Target,info,{CFrame = CFRAME*CFrame.new(Vector3.new(25,0,0))})
tween:Play()
end
end)
Mouse.Button1Up:Connect(function()
if CFRAME then
print(Target.Velocity)
tween:Cancel()
end
for i,v in pairs(Target:GetChildren()) do
if v:IsA("Attachment") then
v:Destroy()
end
end
script.Box.Adornee = nil
end)
this is my code and now idk why that happens? i am just using is CFRAME and when i stop holding the mouse it glitches idk why