Unable to cast value to function

I dont get why this is happening. I am using a remote event. Here is my code.

local event = game.ReplicatedStorage.RedTower
local frame = script.Parent.Parent.Waiting.Frame
local udim = UDim2.new(15,16,61,72)

event.OnClientEvent:Connect(function()
	frame:TweenPosition(udim,2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,-1,true,0) 
end)

The bug appears on the frame:TweenPosition code.

3 Likes

Double check your parameters for TweenPosition().

It should be TweenPosition(Position, EasingDirection, EasingStyle, Time, Override, Callback)

It appears you put an integer value in place of the EasingDirection.

3 Likes

The order of the parameters needs to be these:
TweenPosition(endPosition, easingDirection, easingStyle, time, override, callback)

Just change it to something like this:

frame:TweenPosition(udim, Enum.EasingDirection.Out, Enum.EasingStyle.Linear, -1, true) 
1 Like

I have modified my code to

local event = game.ReplicatedStorage.RedTower

local frame = script.Parent.Parent.Waiting.Frame

local udim = UDim2.new(15, 16, 62, 72)

event.OnClientEvent:Connect(function()

frame:TweenPosition(udim,Enum.EasingDirection.Out,Enum.EasingStyle.Linear,2,true,0)

end)

and it still has the same error message

1 Like

Remove the 0 from the end of the TweenPosition

Like this:

frame:TweenPosition(udim, Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 2, true)

It no longer has the error, but it still does not work.

1 Like

switch Enum.EasingDirection and Enum.EasingStyle around

oh wait, this is a method not the service

1 Like

I tested it here, with the same code and it’s working, maybe the event is not being fired

2 Likes

a hint, you could decrease the size of the parameters with this:

local event = game.ReplicatedStorage.RedTower
local frame = script.Parent.Parent.Waiting.Frame
local udim = UDim2.new(15, 16, 62, 72)

event.OnClientEvent:Connect(function()
	print("Event is fired") -- To know when the event is fired, you can delete this when you want
	frame:TweenPosition(udim, "Out", "Linear", 2, true)
end)

Using “Out” or “Linear” will have the same result, but will facilitate reading.