"Unable to cast object to Object" error

Hi, my name is DarkMenacing

I was coding a button script but when i tested it, it printed out in the exit “Unable to cast object to Object”, i dont know what the error is. also here the script:

local TweenService = game:GetService("TweenService")
local SoundService = game:GetService("SoundService")
local Info = TweenInfo.new(.25, Enum.EasingStyle.Sine, Enum.EasingDirection.In)

function MouseEnter()
	local Tween1 = TweenService:Create(script.Parent, Info, {Size = UDim2.new(0, 110,0, 110)})
	local Tween2 = TweenService:Create(script.Parent.Emoji, Info, {Size = UDim2.new(0, 101,0, 81)})
	local Tween3 = TweenService:Create(script.Parent.Text, Info, {Size = UDim2.new(0, 109,0, 26)})
	
	Tween2:Play()
	Tween3:Play()
	Tween1:Play()
end

function MouseLeave()
	local Tween1 = TweenService:Create(script.Parent, Info, {Size = UDim2.new(0, 101,0, 101)})
	local Tween2 = TweenService:Create(script.Parent.Emoji, Info, {Size = UDim2.new(0, 81,0, 73)})
	local Tween3 = TweenService:Create(script.Parent.Text, Info, {Size = UDim2.new(0, 100,0, 26)})
	
	Tween2:Play()
	Tween3:Play()
	Tween1:Play()
end

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

Anything can help! - Darkmenacing

The script may be confusing the Text property with an object with the same name.

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