[2.0] WCS - A combat system framework

Hey, i use the On Moveset changed, is it a function?, because when i do Character.MovesetChanged:Connect(function(newmoveset, oldmoveset) on the client, it doesn’t works

possibly doesn’t fire first time, running the callback for :GetMovesetName(), nil

1 Like

error

Players.SanJoseYTXD.PlayerScripts.ClientInitializer:72: attempt to index nil with ‘Connect’ - Client - ClientInitializer:72
18:29:44.072 Stack Begin - Studio
18:29:44.072 Script ‘Players.SanJoseYTXD.PlayerScripts.ClientInitializer’, Line 72 - Studio - ClientInitializer:72
18:29:44.072 Stack End - Studio

Can’t tell whats wrong without seeing your code

Nevermind, i got it fixced, anyways, i found another error, there’s no message printed on the console

here’s my modules

clientHandler Module :sweat_smile:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local modules = ReplicatedStorage:WaitForChild("modules")
local WCS = require(modules:WaitForChild("wcs"))
local Skills = ReplicatedStorage:WaitForChild("skills")
local skillsFolder = ReplicatedStorage:WaitForChild("skills")

local HakariFolder = Skills:WaitForChild("hakari")
local localfolder = HakariFolder:WaitForChild("local")
local uisFolder = HakariFolder:WaitForChild("uis")
local hakari_clientUI = uisFolder:WaitForChild("hakari_client")

local handle_client = WCS.RegisterSkill("ClientHandler")
local players = game:GetService("Players")

local localPlayer = players.LocalPlayer
local Character = WCS.Character

local UserInputService = game:GetService("UserInputService")

function handle_client:getCurrentWCS_Character()

	local characterModel = localPlayer.Character
	if not characterModel then return end

	return Character.GetCharacterFromInstance(characterModel)

end



function handle_client:OnConstructClient()
	print("Hi, client handler constructed on client ")
	
	-- get some skills hakari // --

	self.getlightcombat = self.Character:GetSkillFromString("lightcombat")
	
	
	
	-- ///// common variables
	
	local player = self.Player
	local character = player.Character
	
	-- /////
	
	--self.Destroyed:Connect(function()
	--	self.Theme:Stop()
		--self.cloneHakariUI:Destroy()
	--end)
	
	-- // self. variables
	
	self.cloneHakariUI = hakari_clientUI:Clone()
	self.cloneHakariUI.Parent = player.PlayerGui
		
	self.Theme = self.cloneHakariUI:WaitForChild("jackpot")
	self.Theme.Looped = true
	self.Theme:Play()
	
	-- ///////
	
	
	-- charactersSkillsModules.lua --

	-- ///////////

	-- moveset table --

	local movesetNames = {

		[1] = {
			movesetName = "hakari",
			skillsNames = {
				"lightcombat",
			}
		},
	}

	local WCS_Char = self.getCurrentWCS_Character()

	-- // hakari  // --

	-- dw


	local hakariMoveSetTable = movesetNames[1]
	local hakariMoveSetName = hakariMoveSetTable.movesetName
	local hakariMoveSetSkills = hakariMoveSetTable.skillsNames

	local lightcombatName = hakariMoveSetSkills[1]


	UserInputService.InputBegan:Connect(function(Input, GameProcessed)
		if GameProcessed then return end
		if Input.UserInputState ~= Enum.UserInputState.Begin then return end


		if Input.UserInputType == Enum.UserInputType.MouseButton1 then
			local character = self.getCurrentWCS_Character()
			if not character then return end

			if character:GetMoveset(hakariMoveSetName) then
				for _, skillsnames in pairs(hakariMoveSetSkills) do
					if skillsnames then
						if character:GetSkillFromConstructor(lightcombatName) then 
							self.getlightcombat:Start()
						else
							warn("no lightcombat for ".. localPlayer:GetFullName())
						end
					end
				end
			else
				warn("no moveset named ".. tostring(hakariMoveSetName) .. " for ".. localPlayer:GetFullName())
			end
		end

	end)
	
	
	--print(self.getlightcombat:GetCooldownTimeLeft())
	--print(self.getlightcombat:getstate())
	
	
	
end

function handle_client:HandleServerMessage(message)
	if message == "disableTheme" then
		warn("DISABLED THEME WOWOWWWWW")
	end
end


return handle_client

ServerHandler Module :

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local modules = ReplicatedStorage:WaitForChild("modules")
local WCS = require(modules:WaitForChild("wcs"))
local Skills = ReplicatedStorage:WaitForChild("skills")
local skillsFolder = ReplicatedStorage:WaitForChild("skills")

local HakariFolder = Skills:WaitForChild("hakari")
local localfolder = HakariFolder:WaitForChild("local")
local uisFolder = HakariFolder:WaitForChild("uis")
local hakari_clientUI = uisFolder:WaitForChild("hakari_client")

local handle_server = WCS.RegisterSkill("ServerHandler")

local players = game:GetService("Players")

local Character = WCS.Character



function handle_server:OnConstructServer()
	print("Hi, server handler constructed on server ")	
	
	local player = self.Player
	local charactermodel = player.Character
	local Humanoid = charactermodel:WaitForChild("Humanoid") or charactermodel:FindFirstChildWhichIsA("Humanoid")
	task.wait(.1)
	if Humanoid then
		warn("got hum")
		Humanoid.Died:Once(function()
			warn("send")
			self:SendMessageToClient("disableTheme")
		end)
	end
	
	
	
end

function handle_server:HandleClientMessage(type_)
	if type_ == "nil" then
		warn("wowwwwwwwwwww")
	end
end



return handle_server

The bug here is that it doesn’t fires when i send the “disableTheme” message to the client, why?

specifics parts :

if Humanoid then
		warn("got hum")
		Humanoid.Died:Once(function()
			warn("send")
			self:SendMessageToClient("disableTheme")
		end)
	end

function handle_client:HandleServerMessage(message)
	if message == "disableTheme" then
		warn("DISABLED THEME WOWOWWWWW")
	end
end

this is how i organized my things :

image

those shouldn’t be skills at all

1 Like

yeahh, i am still searching for a good way of handling this, but since your module provides all of these, it comes in handy to me, But this normally would work, even if it’s a skill , right?

right now everything works (i am surprised it does, honestly) , but doesn’t sends the message

Alright so, i did some prints and found this, don’t know if it has something to do but anyways

image

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local modules = ReplicatedStorage:WaitForChild("modules")
local WCS = require(modules:WaitForChild("wcs"))
local Skills = ReplicatedStorage:WaitForChild("skills")

local handle_server = WCS.RegisterSkill("ServerHandler")

local players = game:GetService("Players")

local Character = WCS.Character



function handle_server:OnConstructServer()
	print("Hi, server handler constructed on server ")	
	
	local player = self.Player
	local charactermodel = player.Character
	local Humanoid = charactermodel:WaitForChild("Humanoid") or charactermodel:FindFirstChildWhichIsA("Humanoid")
		
	self.getclienthandler = self.Character:GetSkillFromString("ClientHandler")
	self.player = self.Player
	self.charactermodel = self.Player.Character
	self.Humanoid = self.charactermodel:WaitForChild("Humanoid") or charactermodel:FindFirstChildWhichIsA("Humanoid")
	
	task.wait(.1)
	
	if Humanoid then
		warn("got hum")
		Humanoid.Died:Once(function()
			warn("send")
		
		
			self:SendMessageToClient("disableTheme")
			print(self.getclienthandler)
			print(self)
			
		end)
	end
	
	
	
end

function handle_server:OnStartServer()
	print("Hi, server handler started on server ")
	

end
 
--function handle_server:HandleClientMessage(type_)
	--if type_ == "nil" then
	--	warn("wowwwwwwwwwww")
	--end
--end



return handle_server

this isn’t something should be stored in a skill.
wcs covers only the combat system, not your whole game

Is the checkedByOthers property bugged? Or am I just using it wrong. I have a sprint skill that I don’t want other skills to check, so that they can activate while the player is sprinting. I had assumed checkedByOthers would do this, but it doesn’t seem to be working.

function Sprint:OnConstructServer()
	self:SetMaxHoldTime(nil)
	self.CheckOthersActive = false
	self.CheckedByOthers = false
end

Unit tests show everything works as intended. Make sure you’re on the latest version.

1 Like

My bad, just updated and it works fine now

1 Like

I’m curious as to how you were able to do the m1s for your short clip progress. I was able to get it to work but sometimes it’s inaccurate. Mind giving a hand a lil? Enlighten me🙏

Going forward releasing a new WCS version soon.

What features do you think wcs currently lacks?

2 Likes

a built-in cooldown timer time left print, instead of doing a loop ourselves

fixing the send message to client function

and maybe maybe, a function similar to registerSkill() called registerServer(), sorry but i am using it as a server and client handler, if you don’t want this i get it, it’s unrelated to your combat framework anyways

a built-in cooldown timer time left print, instead of doing a loop ourselves

already implemented

fixing the send message to client function

messages are going to be revamped completely

1 Like

that’s cool, also, i think the order i set the moveset skills it’s weird, i mean, it changes and sometimes breaks the skills or just doesn’t starts

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local WCS = require(ReplicatedStorage.WCS)
local Skills = ReplicatedStorage.Skills

local Fireball = require(Skills.Fireball)
local Manashot = require(Skills.Manashot)
local Flight = require(Skills.Flight)

return WCS.CreateMoveset("Mage", {Fireball, Manashot, Flight}) -- another order

if you can, could you check that

can you change movesets while still alive or do you need to reset?

1 Like

got another suggestion, maybe you could add different functions to the WCS character, i noticed ApplyMoveset and ClearMoveset, doesn’t actually cleans the skills, i got a client skill, that only works on client, and when i do the clear moveset function, it doesn’t deletes all related to that skill, functions and that, so yeah, you could either make another clear moveset parameter to clean everything, or modify it if this it’s not the intended behavior, don’t rushing you but… really needing this so i can continue on my project, please correct me if i am wrong

Players.PlayerAdded:Connect(function(player: Player) 
		player.CharacterAdded:Connect(function(CharacterModel)

			local WCS_Character = Character.new(CharacterModel)

			task.delay(9, function()
				WCS_Character:ApplyMoveset(hakari)
				task.wait(9)
				WCS_Character:ApplyMoveset(SSChara) -- doesn't cleans the client and server skills
			
				
			end)
			
			local Humanoid = CharacterModel:WaitForChild("Humanoid") or CharacterModel:FindFirstChildWhichIsA("Humanoid")
			
			Humanoid.Died:Once(function()
				WCS_Character:Destroy()
				warn(Humanoid:GetFullName().. " Died")
			end)

		end)
	end)

How do you define cleanup? 20charsssss