So I have 2 functions which I will connect both when a remote event is fired from the client.
I want
return verifySuccess
to be used in processRequest()
Basically the player makes a request to own a tycoon, the verify function checks to see if they are already owning a tycoon and if they dont returns verifySuccess true,
look at this code here:
local success = nil
local verifySuccess = nil
-- verify
local function verify(player)
if PlayerValues:FindFirstChild(player.Name).IsOwningTycoon == false then
verifySuccess = true
return verifySuccess
else
end
end
local function processRequest()
end
ClaimRequest.OnServerEvent:Connect()
How do I make processRequest() know that verifySuccess is true?
This is quite simple actually. In your verify function, the last line stated, return verifySuccess. So when you call that function, if you put it in a variable, the value that is returned gets stored in that variable. Here’s an example code:
local function hi(something)
if something == true then
return "ItsTrue"
end
-- Now I will declare a variable to call the function
local var = hi(true)
print(var)
-- It should print, ItsTrue when run.
local myRemoteFunction = game:GetService('ReplicatedStorage').RemoteFunction
local isSuccessful = myRemoteFunction:InvokeServer()
assert(isSuccessful, 'Oh no! I already own a tycoon!')
Server:
local myRemoteFunction = game:GetService('ReplicatedStorage').RemoteFunction
local function verify(player) -- check if they own a tycoon
return PlayerValues:FindFirstChild(player.Name).IsOwningTycoon == false
end
myRemoteFunction.OnServerInvoke = function(player)
local playerCanGetTycoon = verify(player)
if playerCanGetTycoon then
-- not sure how you're going about claiming tycoons but that would probably be done here
end
return playerCanGetTycoon
end