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?
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...