Okay, I am working on a game which includes an NPC that if you collect for example 10 coins, you get 200 diamonds. How do I make it so you can only complete the mission and if you come back again in another server and also the same server, it runs a different function, like: 'print(“Already completed”) and never lets you complete the mission again on the same account.
local used = false
local function giveCoins()
if used then --if used is true (if used) and the function is called then abruptly end the function
return
end
local used = true
print("Hello world!")
--perform code here
end
giveCoins() --Hello world! is printed
giveCoins() --nothing happens
If this doesn’t need to persist across multiple server instances then you can simply use the logic as exemplified in the above in order to define a function of which its body (code content) can only be executed once.