TextButton not tweening

Hello, I was working with some tweens when I came across this problem. I am using the new cornerUI element and am tweening a textbutton after the mouse hovers over it. Here is the local script :

script.Parent.MouseEnter:Connect(function()
	game.StarterGui.HomeScreen.BackCharacter:TweenPosition(UDim2.new(0.185, 0, 0.12, 0), Enum.EasingDirection.In, Enum.EasingStyle.Bounce, .5, false, true)
end)

I get this error when hovering over it: “Unable to cast value to function”. I am thinking this is something to do with cornerUI since when I use the same code for previous guis not using cornerUi it works fine.

and I’m going to address this now, This should go in #help-and-feedback:art-design-support since its related to Ui and tweening.

1 Like

Did you use the CornerUi service? I would try to duplicate the script to a ui that doesn’t use CornerUi.

Did you mean to use PlayerGui instead of StarterGui?

Make sure its a localscript. Also, where is it located?

@VegetationBush is correct.

It should be a LocalScript and should be tweened from the PlayerGui not the StarterGui.

You can probably use parents; if not use Player.PlayerGui.

If you do this and it still errors, may I see your explorer tree?

here is my player tree: Screen Shot 2020-06-19 at 10.25.52 AM

its a local script and it is currently in startergui

Still displays the same error, here is my updated script using PlayerGui:

game.Players.LocalPlayer.PlayerGui.DeathSCreen.BackCharacter.BallCustom.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer.PlayerGui.DeathSCreen.BackCharacter:TweenPosition(UDim2.new(.5, 0, .5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 4, true, true)
end)

It won’t work if the parent is the StarterGui, since you can’t tween a service.

StarterGui is simply the place where GuiObjects are duplicated to a player’s PlayerGui, just as the case with StarterPlayerScripts, and a player’s PlayerScripts.

local Players = game:GetService("Players") -- gets the "Players" service
local LocalPlayer = Players.LocalPlayer -- get's the local-player's "Player" object
local PlayerGui = LocalPlayer.PlayerGui -- get's the local-player's PlayerGui

local DeathScreen = PlayerGui:WaitForChild("DeathSCreen") -- gets the "DeathSCreen"
local BackCharacter = DeathScreen:WaitForChild("BackCharacter") -- gets the "BackCharacter"

script.Parent.MouseEnter:Connect(function() -- same code as before (mostly)
    BackCharacter:TweenPosition(UDim2.new(0.185, 0, 0.12, 0), Enum.EasingDirection.In, Enum.EasingStyle.Bounce, .5, false, true)
end)

there is now this error: 10:57:36.247 - Infinite yield possible on ‘Players.RobloxianLegend89.PlayerGui:WaitForChild(“HomeScreen”)’ and it still does not work.

I have edited my post. It should work now. :slight_smile: