Unable to cast value to function (gui tween)

Hello Roblox Dev Community,

Info
I am creating an tween when i step on a block.

Footage

Footage
--{ Variables }--
local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer

local shop = workspace.ShopHitbox
local frame = script.Parent.Frame

--{ Functions }--
shop.Touched:Connect(function(hit)
	wait(.01)
	if plrs:FindFirstChild(hit.Parent.Name) then
		frame:TweenPosition(
			UDim2.new(0, 0, 0 ,0),
			Enum.EasingDirection.In,
			Enum.EasingStyle.Quad,
			.5,
			true,
			false
		)
	end
end)

shop.TouchEnded:Connect(function(hit)
	wait(.01)
	if plrs:FindFirstChild(hit.Parent.Name) then
		frame:TweenPosition(
			UDim2.new(-1, 0, 0, 0),
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Quad,
			.5,
			true,
			false			
		)
	end
end)

Unable to cast value to function - Client - Main:26

What happens
It gives me an error what i showed before and does nothing else.

I would really appericiate any help,
I hope ur having an good day!

Cya :wave: :waffle:

Remove false at the end of your tween. You are setting a callback (function) as a value (false). Example here:

--{ Variables }--
local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer

local shop = workspace.ShopHitbox
local frame = script.Parent.Frame

--{ Functions }--
shop.Touched:Connect(function(hit)
	wait(.01)
	if plrs:FindFirstChild(hit.Parent.Name) then
		frame:TweenPosition(
			UDim2.new(0, 0, 0 ,0),
			Enum.EasingDirection.In,
			Enum.EasingStyle.Quad,
			.5,
			true
		)
	end
end)

shop.TouchEnded:Connect(function(hit)
	wait(.01)
	if plrs:FindFirstChild(hit.Parent.Name) then
		frame:TweenPosition(
			UDim2.new(-1, 0, 0, 0),
			Enum.EasingDirection.Out,
			Enum.EasingStyle.Quad,
			.5,
			true	
		)
	end
end)

If you don’t need the parameter, simply don’t put anything there.

1 Like

You are a legend! Thank you so much!

1 Like

This is competely unnecessary but if for whatever reason you really want to pass an argument for all parameters you can pass nil and Lua will ignore it.

1 Like