Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Attempt to call a boolean value. Any fixes?

Asked by 4 years ago

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)
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. ede2355 22 — 4y
0
Both scripts get the same error. ElpersonPL 44 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
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
Ad

Answer this question