When making a summoning system, where you have rarities and the person pays an amount to pull an object. Do you use remote events from client to server to client? Or do you use remote functions instead? Does it make a difference? Or is there a more efficient and seamless way to do this?
I’m not asking about how to make the system itself, but just how it would be approached (deduction of paid currency and presenting the reward)
Client: To check whether they clicked the button for the GUI interface
Server: To deduct currencies accordingly and reward accordingly the object gained
Client: To “present” the reward, like those egg hatching animations from simulators
General key rule of thumb is to use RemoteFunctions when you want to return a value / yield. And RemoteEvents everywhere else.
For a summoning system, you should use a RemoteFunction since you can return the hatched pets, which can then be used in the animation.
-- server
RemoteFunction.OnServerInvoke = function(player, egg)
-- do logic here
player.Cash.Value -= 100
local hatchedPets = {"dog"}
return hatchedPets -- gets returned to the client
end
-- client
HatchButton.MouseButton1Click:Connect(function()
local hatchedPets = RemoteFunction:InvokeServer("basic egg") -- remote function returns the value
doHatchAnimation(hatchedPets)
end)
I’m already using modulescripts to return the pet. I’m referring to the local script side, where you’d have a button that the player would click to summon the pets. I don’t think it’s wise to do the deductions and changes on the client side so I just want to fire the click of the button, along with the fact whether it was a 10x or 1x summon. In that case, would the only viable method be remote events?