TweenService:Create failed because Instance is null
my script
local function BarrageVFX()
local function CreateArms()
local function CreateArm()
function CleanPart(part)
for _,i in pairs(part:GetDescendants()) do
if i:IsA("Motor6D") or i:IsA("Weld") then
i:Destroy()
end
end
end
spawn(function()
local Chand = Instance.new("Model")
Chand.Parent = game.Workspace
Chand.Name = "Handssssss"
local Arm
local Lower
local Hand
local p1
local ChooseDirection = math.random(1,4)
local p0 = Stand.HumanoidRootPart.Position
if ChooseDirection == 1 then
Arm = Stand.LeftUpperArm:Clone()
CleanPart(Arm)
Arm.Parent = Chand
Lower = Stand.LeftLowerArm:Clone()
CleanPart(Lower)
Lower.Parent = Chand
Hand = Stand.LeftHand:Clone()
CleanPart(Hand)
Hand.Parent = Chand
Arm.Name = "Arm"
Lower.Name = "Lower"
Hand.Name = "Hand"
p1 = Stand.HumanoidRootPart.Left.WorldPosition + Vector3.new(0,math.random(-5,5),0)
elseif ChooseDirection == 2 then
Arm = Stand.RightUpperArm:Clone()
CleanPart(Arm)
Arm.Parent = Chand
Lower = Stand.RightLowerArm:Clone()
CleanPart(Lower)
Lower.Parent = Chand
Hand = Stand.RightHand:Clone()
CleanPart(Hand)
Hand.Parent = Chand
Arm.Name = "Arm"
Lower.Name = "Lower"
Hand.Name = "Hand"
p1 = Stand.HumanoidRootPart.Right.WorldPosition + Vector3.new(0,math.random(-5,5),0)
elseif ChooseDirection == 3 then
Arm = Stand.RightUpperArm:Clone()
CleanPart(Arm)
Arm.Parent = Chand
Lower = Stand.RightLowerArm:Clone()
CleanPart(Lower)
Lower.Parent = Chand
Hand = Stand.RightHand:Clone()
CleanPart(Hand)
Hand.Parent = Chand
Arm.Name = "Arm"
Lower.Name = "Lower"
Hand.Name = "Hand"
p1 = Stand.HumanoidRootPart.Up.WorldPosition + Vector3.new(0,math.random(3,5),0)
elseif ChooseDirection == 4 then
Arm = Stand.LeftUpperArm:Clone()
CleanPart(Arm)
Arm.Parent = Chand
Lower = Stand.LeftLowerArm:Clone()
CleanPart(Lower)
Lower.Parent = Chand
Hand = Stand.LeftHand:Clone()
CleanPart(Hand)
Hand.Parent = Chand
Arm.Name = "Arm"
Lower.Name = "Lower"
Hand.Name = "Hand"
p1 = Stand.HumanoidRootPart.Down.WorldPosition + Vector3.new(0,math.random(-5,-3),0)
end
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = Hand
Weld.Part1 = Lower
Weld.Parent = Hand
local wedl = Instance.new("WeldConstraint")
wedl.Part0 = Arm
wedl.Part1 = Lower
wedl.Parent = Arm
Chand.PrimaryPart = Lower
Chand.PrimaryPart.Anchored = true
Chand.PrimaryPart.CanCollide = false
local p2 = Stand.HumanoidRootPart.End.WorldPosition
local TweenDelay = wait()
function lerp(a, b, c)
return a + (b - a) * c
end
function quadBezier(t, p0, p1, p2)
local l1 = lerp(p0, p1, t)
local l2 = lerp(p1, p2, t)
local quad = lerp(l1, l2, t)
return quad
end
for i = 1, 20 do
local t = i/20
local pos = quadBezier(t, p0, p1, p2)
local Direction = quadBezier(t + 0.5, p0,p1, p2)
local movetween = game.TweenService:Create(Chand.PrimaryPart,TweenInfo.new(TweenDelay),{CFrame = CFrame.new(pos, Direction) * CFrame.Angles(math.rad(90),0,0)})
local Time = 0.50
local TimeT = 0.50
movetween:Play()
movetween.Completed:Connect(function()
game.Debris:AddItem(Chand,Time)
for i, v in pairs(Chand:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") then
game.TweenService:Create(v,TweenInfo.new(TimeT),{Transparency = 1}):Play()
end
end
end)
wait()
end
end)
end
CreateArm()
CreateArm()
CreateArm()
CreateArm()
end
CreateArms()
end