Problem with simple UI tweening

So i’m trying to make a simple UI that moves to the screen when a button is activated. I’ve done the a million times, but it seems like i forgot it, because i have an error that’s saying :
"TweenService:Create no property named 'Position' for object 'BuyCoins' "
Well i don’t know what is the problem so here is my script :

local openedPosition = UDim2.new(0.175, 0,0.328, 0)
local closedPosition = UDim2.new(-0.35, 0,0.328, 0)

local CoinsFrame = script.Parent.BuyCoins

local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false)

local isOpened = false

script.Parent.Activated:Connect(function()
	if isOpened == false then
		TweenService:Create(CoinsFrame, Info, {Position = openedPosition}):Play()
		isOpened = true
	elseif isOpened == true then
		TweenService:Create(CoinsFrame, Info, {Position = closedPosition}):Play()
		isOpened = false
	end
end)

Is the script also named “BuyCoins”? It could be that the script is accidently referring to itself.

1 Like

TweenService and ui is kinda broken unless u are trying to change the ui.rotation then its not great to use it (its not optimized for ui)

I’ll use the built in tween function built into uis for this script :smiley::fearful:

local openedPosition = UDim2.new(0.175, 0,0.328, 0)
local closedPosition = UDim2.new(-0.35, 0,0.328, 0)

local CoinsFrame : Frame = script.Parent.BuyCoins

local isOpened = false

script.Parent.Activated:Connect(function()
	if isOpened == false then
		CoinsFrame:TweenPosition(openedPosition, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
		isOpened = true
	elseif isOpened == true then
		CoinsFrame:TweenPosition(closedPosition, Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.5)
		isOpened = false
	end
end)

Feel free to ask me any other questions
Hope this helps :nail_care:t2:

:TweenPosition has been deprecated, it is better to use TweenService now.

2 Likes

NOOOOOOO DONT TELLL ME IM GONNA SEE MODULES OFF “TweEnPosItion”
but like why isnt it deprecated in rblx studio? it doesnt say that- am i late or something?

Probably but I can’t care much about them, I don’t use community made modules.

It is, you can use it but it is recommended to use TweenService as said by roblox when you try to call the method.

1 Like

JUST CHECKING! is the script on a local script or a server script? (it’s really dumb for me to ask but is it?)

Oh it is. I didn’t notice that, now it works completly fine. Thanks!

Local or server, it doesn’t matter in starter gui as it would still run.

Haha yeah, that’s a common mistake, glad that it’s fixed.

1 Like

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