How to make an object go to a gui?

“Expected a name, got a complex expression” I have 0 clue what this could mean. This is for the “image.Position”

My bad

local Tween = TweenService:Create(Image, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), { Position = player.PlayerGui.Profile.Frame.Cash.Position })
Tween:Play()
Tween.Completed:Connect(function()
-- no tabs because mobile
image:Destroy()
end)

This is what happens?? Any help?

Try changing the tween.completed event to this:

Tween.Completed:Connect(function(playbackState)
if playbackState == Enum.PlaybackState.Completed then
Image:Destroy()
end
end

Still doing the same thing, I have no idea why either.

Just remove the tween.completed entirely.

Now it just does nothing??? It just sits there like before.

Did you play the tween using tween:Play()?

Yes, and it hasn’t done anything (sorry for the late reply)

Try tweening the position instead


image:TweenPosition(player.PlayerGui.Profile.Frame.Cash.Position)

This is what you meant correct?

local Tween = TweenService:Create(Image, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), { Image:TweenPosition(player.PlayerGui.Profile.Frame.Cash.Position) })

Tween:Play()

end)

if so “Unable to cast to dictionary” error again.

No, I mean replace all that Tweening stuff with that function

image:TweenPosition(player.PlayerGui.Profile.Frame.Cash.Position)

end)

Its doing the same thing as before, no idea why.

I changed “Image” to “Gui” and it went to the top left corner, isntead of going down left corner??

I’m confused as well. I really don’t know what’s going on.

Me neither. ill try to see what I can do to fix this but i have 0 clue.

The main problem here is you need to tween to the AbsolutePosition of what you want to move to. Grab the AbsolutePosition of the cash frame and convert it to UDim2 with UDim2.fromOffset(player.PlayerGui.Profile.Frame.Cash.AbsolutePosition.X, player.PlayerGui.Profile.Frame.Cash.AbsolutePosition.Y).

You can plug this into your TweenService Create which you had right, the last parameter was wrong though. It takes a dictionary of Property = Value.

Instead of

{ Image:TweenPosition(player.PlayerGui.Profile.Frame.Cash.Position) }

You should be doing

{
    Position = UDim2.fromOffset(player.PlayerGui.Profile.Frame.Cash.AbsolutePosition.X, player.PlayerGui.Profile.Frame.Cash.AbsolutePosition.Y)
}

And finally given this change, you want to tween Gui instead of Image as you’re getting mixed results because positions are relative to the parent. Which is also the issue described above with getting the AbsolutePosition of the cash frame as the position of that is relative to the parent Profile.Frame

3 Likes

So this is what I did. Any instead of like moving towards it, it goes RIGHT to it. any help?

local TweenService = game:GetService(“TweenService”)

Gui.Position = UDim2.fromOffset(player.PlayerGui.Profile.Frame.Cash.AbsolutePosition.X, player.PlayerGui.Profile.Frame.Cash.AbsolutePosition.Y)

end)

You’re setting the position value instead of tweening it.

Use this as you had before but replace Image with Gui in the first parameter and the last parameter to be the proper dictionary I gave above.

2 Likes

It goes straight down? Is this the script or the gui?