Type '(any) -> ()' could not be converted into '(any) -> g52'

BindableEvent invoke gives strange error.

OnButtonPressed.OnInvoke = function(Response)
	
end

In the script editor this is underlined for some reason.

When I hover on it, it says " Type ‘(any) → ()’ could not be converted into ‘(any) → g52’ ". Can anyone tell me how to fix this?

I am using --!strict by the way, please don’t ask me to remove it, I want to solve this error without removing strict.

1 Like

Do you have any code within that function yet? If so, what is it and what are you returning? Also, I assume you mean a RemoteFunction and not a RemoteEvent?

2 Likes

@sleitnick @takticiadam
It’s a BindableFunction.

Here is the code, its being used in SendNotification by the way.

local OnButtonPressed: BindableFunction = Instance.new("BindableFunction")

OnButtonPressed.OnInvoke = function(Response: string)
	if (Response == "Yes") then
		MarketplaceService:PromptProductPurchase(LocalPlayer,1121741086)
		return true
	end
	return false
end

OnButtonPressed.Parent = script

StarterGui:SetCore("SendNotification",{
		Title = "place holder",
		Text = "place holder",
		Icon = "place holder",
		Button1 = "Yes",
		Button2 = "No",
		Callback = OnButtonPressed
	})

I think this is just a bug with the type-checker, or at least with the configuration of BindableFunctions. Your code is valid. It only one return type (boolean), and the type-checker seems to pick up on that fine.

I wonder what “g33” is supposed to be?

2 Likes

Whats the error? you just added the “: string” thing but you didnt explain whats wrong

I have mentioned it in the screenshot.

My bad, sorry it was really small that not enough to me notice it.

Have you tried specifying the return of the function? Whatever g33 is could be a default that’s throwing it off.

3 Likes