For some reason the tween sometimes tweaks out and goes completely ballistic I dont know if I did it wrong? I mean it works fine but when I look at a specific angle it starts doing whatever this is?
do
local Debounce = 0.2
local Object = Model["Meshes/iceSpikesSav_Plane.001"]:Clone()
Object.Transparency = 1
Object.CanCollide = false
Object.Anchored = true
Object.Size = Object.Size / 1.2
-- OnSpawn Position
local forwardOffset = 15
local upOffset = -1.9
local rightOffset = 0
-- OnSpawn Rotation
local rotX = math.rad(0)
local rotY = math.rad(175)
local rotZ = math.rad(0)
-- Mathematical calculations to determine the final position
local lookVector = HRP.CFrame.LookVector
local upVector = HRP.CFrame.UpVector
local rightVector = HRP.CFrame.RightVector
local spawnPosition = HRP.Position
+ (lookVector * forwardOffset)
+ (upVector * upOffset)
+ (rightVector * rightOffset)
local baseCFrame = CFrame.new(spawnPosition, spawnPosition + lookVector)
local finalCFrame = baseCFrame * CFrame.Angles(rotX, rotY, rotZ)
Object.CFrame = finalCFrame
Object.Position = spawnPosition
-- Tween to Position
local tweenForwardOffset = 5
local tweenUpOffset = 0
local tweenRightOffset = 0
-- Tween to Rotation
local tweenRotX = math.rad(0)
local tweenRotY = math.rad(180)
local tweenRotZ = math.rad(0)
local targetRotCFrame = baseCFrame * CFrame.Angles(tweenRotX, tweenRotY, tweenRotZ)
local x, y, z = targetRotCFrame:ToEulerAnglesXYZ()
local targetRot = Vector3.new(math.deg(x), math.deg(y), math.deg(z))
local targetPos = spawnPosition
+ (lookVector * tweenForwardOffset)
+ (upVector * tweenUpOffset)
+ (rightVector * tweenRightOffset)
task.delay(0.1, function()
Tween:Play(Object, {Debounce, "Back", "Out"}, {
Transparency = 0,
Position = targetPos,
Size = Object.Size * 1.2
})
Tween:Play(Object, {Debounce, "Quad", "In"}, {
Rotation = targetRot,
})
end)
Object.Parent = Temporary
Debris:AddItem(Object, math.huge)
end