Unable to cast token to token

Error: Unable to cast token to token.

Here is the programming.

local START = UDim2.new(0.05,0,1,0)
local END = UDim2.new(1,0,1,0)

function tweenBegin()
	local frame = script.Parent
	frame.Size = START
	frame:TweenSize(
		Enum.EasingDirection.In,
		Enum.EasingStyle.Linear,
		5,
		true
	)
end

function tweenEnd()
	local frame = script.Parent
	frame.Size = END
	frame:TweenSize(
		Enum.EasingDirection.In,
		Enum.EasingStyle.Linear,
		5,
		true
	)
end

script.Parent.Parent.MouseEnter:Connect(tweenBegin)
script.Parent.Parent.MouseLeave:Connect(tweenEnd)

1 Like

Try this instead.

local START = UDim2.new(0.05,0,1,0)
local END = UDim2.new(1,0,1,0)

function tweenBegin()
	local frame = script.Parent
	frame.Size = START
	frame:TweenSize(
        START,
		Enum.EasingDirection.In,
		Enum.EasingStyle.Linear,
		5,
		true
	)
end

function tweenEnd()
	local frame = script.Parent
	frame.Size = END
	frame:TweenSize(
        END,		
        Enum.EasingDirection.In,
		Enum.EasingStyle.Linear,
		5,
		true
	)
end

script.Parent.Parent.MouseEnter:Connect(tweenBegin)
script.Parent.Parent.MouseLeave:Connect(tweenEnd)

Isn’t this the same as the one I sent above???

At frame:TweenSize() you never had a size for the first argument…

It isn’t tweening smoothly, it’s straight away moving to the right without a slow tween…

Try this one instead

local START = UDim2.new(0.05,0,1,0)
local END = UDim2.new(1,0,1,0)

function tweenBegin()
	local frame = script.Parent
	frame:TweenSize(
        START,
		Enum.EasingDirection.In,
		Enum.EasingStyle.Linear,
		5,
		true
	)
end

function tweenEnd()
	local frame = script.Parent
	frame:TweenSize(
        END,		
        Enum.EasingDirection.In,
		Enum.EasingStyle.Linear,
		5,
		true
	)
end

script.Parent.Parent.MouseEnter:Connect(tweenBegin)
script.Parent.Parent.MouseLeave:Connect(tweenEnd)

And uh also, I can’t change the TopBar Transparency anymore?

You never put anything about transparency in your one…

game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui'):SetTopbarTransparency(0)

local START = UDim2.new(0.05,0,1,0)
local END = UDim2.new(1,0,1,0)

function tweenBegin()
	local frame = script.Parent
	frame.BackgroundTransparency = 0.5
	frame:TweenSize(
		END,
		Enum.EasingDirection.In,
		Enum.EasingStyle.Linear,
		.5,
		true
	)
end

function tweenEnd()
	local frame = script.Parent
	
	frame:TweenSize(
		START,		
		Enum.EasingDirection.In,
		Enum.EasingStyle.Linear,
		.5,
		true
	)
	wait(2)
	frame.BackgroundTransparency = 0 
end

script.Parent.Parent.MouseEnter:Connect(tweenBegin)
script.Parent.Parent.MouseLeave:Connect(tweenEnd)```

Yeah I did, the top, line 1. But it don't work ( the topbar transparency ).

You’ll have to use a frame for that because its deprecated.