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 :
game.StarterGui.HomeScreen.BackCharacter:TweenPosition(UDim2.new(0.185, 0, 0.12, 0), Enum.EasingDirection.In, Enum.EasingStyle.Bounce, .5, false, true)
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.
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
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
You can probably use parents; if not use
If you do this and it still errors, may I see your explorer tree?
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:TweenPosition(UDim2.new(.5, 0, .5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 4, true, true)
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
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)
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.