Tween Unable to cast value to Object

I am trying to Tween the Y-Axis of a head up to a position, then Tween it back down.
However i keep getting spammed this error:

My code:

local module = {}
local TweenService = game:GetService("TweenService")

local tweenInfoUp = TweenInfo.new(0.75, Enum.EasingStyle.Quint)
local tweenInfoDown = TweenInfo.new(0.25, Enum.EasingStyle.Quint)

local rebounce = false

module.TweenObject = function(Object, tGoals)
	print("called")
	if rebounce == false then
		print("true")
		rebounce = true
		local UpTween = TweenService:Create(Object,tweenInfoUp,{CFrame = tGoals.CFrame + Vector3.new(0,5,0)})
		local DownTween = TweenService:Create(Object,tweenInfoDown,{CFrame = tGoals.CFrame})
		local UpTweenHead = TweenService:Create(Object.Parent.Head.CFrame.Y,tweenInfoUp,{Value = Object.Parent.Head.CFrame.Y + 5})
		local DownTweenHead = TweenService:Create(Object.Parent.Head.CFrame.Y,tweenInfoDown,{Value = Object.Parent.Head.CFrame.Y - 5})
		
		UpTween:Play()
		UpTweenHead:Play()
		UpTween.Completed:Connect(function()
			DownTween:Play()
		end)
		UpTweenHead.Completed:Connect(function()
			DownTweenHead:Play()
		end)
	end
	spawn(function()
		wait(1)
		rebounce = false
	end)
	
end

return module

Please let me know if you need more information.

1 Like
local UpTweenHead = TweenService:Create(Object.Parent.Head, tweenInfoUp,{CFrame = Object.Parent.Head.CFrame + Vector3.new(0, 5, 0})
local DownTweenHead = TweenService:Create(Object.Parent.Head, tweenInfoDown,{CFrame = Object.Parent.Head.CFrame - Vector3.new(0, 5, 0})

TweenService first param must be an Instance.

1 Like

try this instead of line 16

local upTweenHead = TweenService:Create(Object.Parent.Head, tweenInfoUp, {CFrame = Object.Parent.Head.CFrame + Vector3.new(0, 5, 0)})

1 Like

Thanks it worked, but it’s doing very weird actions for some reason. It’s not decreasing the right amount.

External Media

I forgot to say I changed line 17 as well.

local DownTweenHead = TweenService:Create(Object.Parent.Head,tweenInfoDown,{CFrame = Object.Parent.Head.CFrame - Vector3.new(0, 5, 0)})

replace the DownTweenHead with this:

local DownTweenHead = TweenService:Create(Object.Parent.Head, tweenInfoDown, {CFrame = Object.Parent.Head.CFrame})

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.