Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Attempt to call a boolean value. Any fixes?

So I tried making a check for my shop so that I don't scam the players. So that if the event isn't running then they won't buy it. And It doesn't work. Here's the code. ServerScript:

local function checkEvent()
	if not EventRunning then
		return true
	else
		return false
	end
end
game.ReplicatedStorage.CheckEvent.OnServerInvoke = checkEvent()

LocalScript:

Frame.ShpBuy2.MouseButton1Click:Connect(function()
	local ChckEvnt = EventCheck:InvokeServer()
	print(ChckEvnt)
	if ChckEvnt then
		MarketService:PromptProductPurchase(plr, 1009546097)
	else
		print("No event is running!")
	end
end)

2 comments

0

Tell me which script is the error occurring in, you can check this by clicking on the error when you get it. But it may be like that because of the return false and return true since both of them are boolean values, otherwise right now, I might 100% sure.

0

Both scripts get the same error.

1 answer

✓ Accepted answer
game.ReplicatedStorage.CheckEvent.OnServerInvoke = checkEvent()

On this line here, you're calling checkEvent and assigning the returned value. Remove the parenthesis to assign the function itself instead:

game.ReplicatedStorage.CheckEvent.OnServerInvoke = checkEvent

This discussion is preserved as it was. New answers, comments, and votes are closed.