I want to create a function which can be called by both clients and server and return some value but I'm kinda lost at this point, what I need to use in this case?
✓ ANSWER ACCEPTED
Global function for both clients and server?
1 answer
✓ Accepted answer
What you're looking for is something called a module script.
What is a module script you may ask? Well a module script is a script that can be required - by the client and the server- and returns something back to the caller (this is normally a table).
For example:
--module
local module = {]
function module:KillCaller(Plr)
Plr.Character.Humanoid.Health = 0
end
return module
--client
local KillKill = path.ModuleScript
local Player = game:GetService("Players").LocalPlayer
KillKill:KillerCaller(Player) -- will kill the client
Module scripts are the best option for the question and can be used in lots of ways:like datastores, 3d triangles and etc...
1 comment
0
Oh, that's exactly what I was looking for! Thank you
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You can create a remoteEvent/Function and then call it from both server and client using either FireClient() from server or FireServer() from client.