Hello! I want to make a combat system that is secure and also has compressed data. I want it to be secure, I have thought of a way but would like any advice/issues with my code from programmers.
This is what the client sends:
local event = game.ReplicatedStorage:WaitForChild("Events"):WaitForChild("Combat"):WaitForChild("UseWeapon")
local tool = script.Parent
tool.Activated:Connect(function()
print("Used Mace")
local weaponData = {2,1}
event:FireServer(weaponData)
task.wait(.05)
end)
This is how the server handles the signal:
--Services--
local HTTP = game:GetService("HttpService")
local SS = game:GetService("ServerStorage")
local RS = game:GetService("ReplicatedStorage")
--Folders--
local CombatEvents = RS.Events.Combat
local CraftableInfo = SS.Modules.CraftableInfo
--Events--
local UseWeaponRE = CombatEvents.UseWeapon
--Modules--
local CombatMod = require(CraftableInfo.Combat)
--//Codes\\--
local WeaponCodes = {
[1] = "Sword",
[2] = "Mace"
}
local ActionCodes = {
[1] = "USE"
}
local function useWeapon(plr: Player, weaponData)
if #weaponData ~= 2 then return end
local weaponName = WeaponCodes[weaponData[1]]
local actionCode = ActionCodes[weaponData[2]]
print("---RECEIVED SIGNAL---")
print("Weapon: "..weaponName)
print("Action: "..actionCode)
end
UseWeaponRE.OnServerEvent:Connect(useWeapon)
I was wondering how secure, compact and scalable this script is. I am just a beginner in scripting so any suggestions are welcome here. I am mainly concerned about the security and the compression of data between remote events.