You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Without using bindable events on the server-end and even the client-end, is there a way my code below can yield the pcall after 5 seconds on the server-end. -
What is the issue? Include screenshots / videos if possible!
Currently, I have the client detecting when 5 seconds passes and returns with a value & no client intervention is detection is connected; however, I’d prefer the Server to handle for security purposes. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried using coroutines and I wasn’t personally able to find a solution. I’ve also used task.delay; however, when I place ‘return’ inside of the delay function it returns, obviously, to the task.delay function. Is there another way I can detect the return from the task.delay?
--- What I mean by 'task,delay'
local success,scanned = pcall(function()
task.delay(function() return true end)
return ReplicatedStorage.Game.RemoteFunctions.LTDJob:InvokeClient(Player,Item)
end)
-- I've also done, return func() 'func is the task.delay function' or InvokeClient()
-- ;however, this does not work as well. This is where my lua knowledge stops.
--- CLIENT CODE
if Item then
local CD = Instance.new("ClickDetector")
CD.Parent = Item
local event = Instance.new("BindableEvent")
local function Fire()
event:Fire()
end
task.delay(5,Fire)
CD.MouseClick:Connect(Fire)
event.Event:Wait()
event:Destroy()
return true
end
--- SERVER CODE
if reduceMoney() then
local success,scanned = pcall(function()
return ReplicatedStorage.Game.RemoteFunctions.LTDJob:InvokeClient(Player,Item)
end)
print(success,scanned)
if FindItem() then FindItem():Clone().Parent = Player.Backpack end
return true
else
Notify()
return false
end