Problem with my modulescript

For some reason my code to animate a frame opening doesnt work.

Here is the module script

	local object = frame
	if object == nil then
		print("error object = nil")
	end
	print(object)
	object.Size = UDim2.fromScale(0, 0)
	task.wait(frameclosespeed*0.1)
	object.Visible = true
	local opentween = tweenservice:Create(object, TweenInfo.new(frameopenspeed, Enum.EasingStyle.Sine, Enum.EasingDirection.In),
		{Size = UDim2.fromScale(0, 0)}
	)
	opentween:Play()
end

and client


script.Parent.MouseButton1Click:Connect(function()

	script.Parent.Parent.Parent.ComputerShop.Enabled = true
	module.OpenFrame(script.Parent.Parent.Parent.ComputerShop.ScrollingFrame)
end)```

You forgot to get the service, Add this at the beginning of your code:

local TweenService = game:GetService("TweenService")

Oh this isnt the full code let me send you the full version

local tweenservice = game:GetService("TweenService")

local frames = script.Parent

local frameopenspeed = 1.2

local frameclosespeed = 0.5

function module.CloseFrame(object)
	local opentween = tweenservice:Create(object, TweenInfo.new(frameopenspeed, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
		{Size = UDim2.fromScale(1, 1)}
	)
end

function module.CloseAllFrames()
	
end


function module.OpenFrame(frame)
	local object = frame
	if object == nil then
		print("error object = nil")
	end
	print(object)
	object.Size = UDim2.fromScale(0, 0)
	task.wait(frameclosespeed*0.1)
	object.Visible = true
	local opentween = tweenservice:Create(object, TweenInfo.new(frameopenspeed, Enum.EasingStyle.Sine, Enum.EasingDirection.In),
		{Size = UDim2.fromScale(0, 0)}
	)
	opentween:Play()
end


return module

Try this code:

object:TweenPosition(Udim2.new(enter your new position/size), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 2) -- the number is the duration of the tween 

I just found out the solution I inverted the process I did 0, 0 instead of 1, 1. Thank you for your help though

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