Hello, I’ve been working on a game, not giving the name but it requires heavy communication (client - module script) and I have to do it on the server because that’s what I considered first and I don’t know how… in conclusion I have to make the client be able to “Own” the module script, here is my code:
This is the template i have to inherit from:
local Services = {
["ContextActionService"] = game:GetService("ContextActionService"),
["UserInputService"] = game:GetService("UserInputService")
}
local MODULES = {
["Ragdoll"] = require(game.ServerScriptService:WaitForChild("ModuleScripts").Misc.RagdollModule)
}
local MISC = {
["NOTHING"] = nil,
["GiveAbility"] = game:GetService("ReplicatedStorage").Events:WaitForChild("GetAbility"),
["Default Push Remote"] = game:GetService("ReplicatedStorage").Events:WaitForChild("CLIENTCOMMUNICATION"),
["COMMUNICATION"] = game:GetService("ReplicatedStorage").Events:WaitForChild("DEFAULTPUSH")
}
local HandTemplate = {}
HandTemplate.__index = HandTemplate
HandTemplate.__newindex = function(entry)
print(tostring(entry).."JOINED THE META TABLE")
end
HandTemplate.NewHand = function(_POWER : number, _HANDNAME : string, _ABILITYNAME : string, _ABILITY, ...)
local _TABLE = table.pack(
)
local OtherArgs = table.pack(...)
table.insert(_TABLE, table.unpack(OtherArgs))
_TABLE.__index = _TABLE
_TABLE.AbilityFunction = _ABILITY
_TABLE.Power = _POWER
_TABLE.HandName = _HANDNAME
_TABLE.AbilityName = _ABILITYNAME
setmetatable(_TABLE, HandTemplate)
print("OBJECT CREATED")
return _TABLE
end
HandTemplate.Init = function(self, DefaultPush : boolean, ABILITY : any, PASSIVE : any)
task.desynchronize()
assert(PASSIVE, "There will be no passive")
assert(ABILITY, "There will be no ability")
if PASSIVE then
task.spawn(function()
PASSIVE()
end)
end
if ABILITY then
MISC["GiveAbility"].OnServerInvoke:Connect(function()
print("ABILITY GIVEN")
return self.Ability, self.AbilityName
end)
end
if DefaultPush then
MISC["COMMUNICATION"].OnServerEvent:Connect(function(Player : Player)
local Character : any = Player.Character or Player.CharacterAdded:Wait()
assert(Character, "CHARACTER IS NIL")
end)
MISC["Default Push Remote"].OnServerEvent:Connect(function(Player:Player, hit : any, humanoid:Humanoid)
local Character : any = humanoid.Parent
local HUMANOID : Humanoid = humanoid
print(Player.Name.."Pushed"..Character.Name)
MODULES["Ragdoll"]:RigPlayer(Character)
HUMANOID:ChangeState(Enum.HumanoidStateType.Ragdoll)
end)
end
task.synchronize()
end
return HandTemplate
this is something that inherits
local HandTemplate = require(script.Parent:WaitForChild("HANDTEMPLATE"))
local function STARTAttributes()
local Session = {}
local _POWER = Instance.new("NumberValue", script)
_POWER.Name = "POWER"
_POWER.Value = 25
table.insert(_POWER, Session)
return Session
end
local Attributes : any = STARTAttributes()
assert(Attributes, "SOMETHING FAILED")
assert(HandTemplate, "HAND TEMPLATE WAS NOT FOUND")
local Default = {}
Default.__index = Default
Default.NEW = function()
local NEW_TEMPLATE = HandTemplate.NewHand(25, "Default", "Fart")
local DefaultHand = setmetatable(NEW_TEMPLATE, Default)
DefaultHand.Initiate = NEW_TEMPLATE.Init
return DefaultHand
end
Default.Initiate = function(self)
self.Initiate(true)
end
return Default
and this is the client script that gives inputs and stuff ( snippet )
-- Listeners
coroutine.wrap(function()
task.desynchronize()
local Ability,AbilityNAME = GETABILITY:InvokeServer()
if Ability then
assert(ContextActionService:BindAction(AbilityNAME, Ability,true,Enum.KeyCode.E), "BIND FAILED")
end
task.synchronize()
end)
LeHitboxe.OnHit:Connect(function(hit : any , humanoid : Humanoid)
CLIENT_Communicator:FireServer("Push", hit, humanoid)
end)
UserInputService.InputBegan:Connect(function(Input,GameProccess)
if GameProccess then return end
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
task.spawn(function()
assert(LeHitboxe:HitStart(), "Unable to start the hitbox")
task.wait(2)
assert(LeHitboxe:HitStop(), "Unable to stop the hitbox, MOST LIKELY EXPLOITER")
end)
end
end)
if i require the default module on the client it works but I have server APIs in there, so I prefer not to do that, also preventing exploiters, so. Does anyone know how can I fix this??
If you need more information please reply, please help me : C
CONCLUSION: HOW DO I MAKE A MODULE SCRIPT BE REQUIRED BY INDIVIDUAL CLIENTS WHILE BEING ON THE SERVER