How would I setup this stance system

Vocab that might be foreign:

Stances: Just different variants of the combat, and different variants of the blocking.

Hello to whoever is reading this. As of recent, I have been attempting a stance system, which uses a Count method to change the animations and what is being done to the opposing player.

What I attempted:

  1. My first attempt was trying to play the animations through the server, and them stopping them after my stance system recognized the release button. The issue was that the release button wasn’t related to the stance system at all, so there was no way to recognize that the animation should be stopped.

  2. My second/current method is updating the animations via the client. With this system there is no real ability to block an opposing stance, but it’ll fool the person using the stance due to the reason that the actual value/attribute that holds the named stance doesn’t change, so they’ll still take damage, even though the animation that is being shown isn’t equal to the character’s current stance.


That’s the result of the first script.

I don’t have a video of the current one, but if requested I’ll add it here. If I could just get a further guidance, or assistance on this system, it’d be very much appericated.

May I see your program, if you are comfortable with sharing it?

Sure.

-- \\ Player-Related Variables // --

local Players = game:GetService("Players");
local Player = Players.LocalPlayer;
local Character = Player.Character or Player.CharacterAdded:Wait();



-- \\ Services // --

local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")

-- \\ Modules // --

local AnimationModule = require(ReplicatedStorage.Modules.GeneralModules.AnimModule)

-- \\ Misc. Variable // --

local Debounce = false
local Count = 0
local ButtonDown = false

local Anim : Animation = {
	AnimationModule.getSingleAnimation(Character:WaitForChild("Humanoid"), script.BlockStances.BaseStance),
	AnimationModule.getSingleAnimation(Character:WaitForChild("Humanoid"), script.BlockStances.UpperStance),
	AnimationModule.getSingleAnimation(Character:WaitForChild("Humanoid"), script.BlockStances.LowerStance)
}

-- \\ Functions // --

local CountChanger = function()
	print(Count)
	if Count <= 3 then
		Count += 1

	elseif Count == 4 then
		Count = 1

	end

end

local AnimationChanger = function()
	
	if Count == 1 then
			print("Why no work")
	Anim[1].Looped = true
	Anim[1]:Play()
		
	elseif Count == 2 then
	Anim[2].Looped = true
	Anim[2]:Play()	
	elseif Count == 3 then
	Anim[3].Looped = true
	Anim[3]:Play()	
		
	end
end

local AnimationStopper = function()
	if Count == 1 then
		Anim[1].Looped = false
		Anim[1]:Stop()

	elseif Count == 2 then
		Anim[2].Looped = true
		Anim[2]:Stop()	
		
	elseif Count == 3 then
		Anim[3].Looped = true
		Anim[3]:Stop()	

	end
	
end

UserInputService.InputBegan:Connect(function(Input, GPE)
	
	
	if GPE == true then return end
	
	
	
	

	if Character:WaitForChild("StatusFolder"):FindFirstChild("Stunned") then
		print('loser')
		return
	end

	if Character:FindFirstChildOfClass("Tool") then
		print('toolienotallowed')
		return
	end

	
	if Input.KeyCode == Enum.KeyCode.F then
		if Debounce == false then
			Debounce = true
			ButtonDown = true
			CountChanger()
			print("goo")
			AnimationChanger()
			
			
			ReplicatedStorage.RemoteEvents.CombatEvents.Blocking:FireServer(Count)
		end
	end
	
	
end)

UserInputService.InputEnded:Connect(function(Input, GPE)
	if GPE == true then return end

	if Character:WaitForChild("StatusFolder"):FindFirstChild("Stunned") then
		print('loser')
		return
	end

	if Character:FindFirstChildOfClass("Tool") then
		print('toolienotallowed')
		return
	end
	
	if Input.KeyCode == Enum.KeyCode.F and ButtonDown == true then
	ReplicatedStorage.RemoteEvents.CombatEvents.Release:FireServer()
		
		Character:SetAttribute("IsBlocking", false)
		ButtonDown = false
		print("uh?")
		AnimationStopper()
		wait(.9)
		Debounce = false
	end
	
end)

This is the current local script, which is handling the animations, but I want it to change the actual stances, located here (In the server.)

StanceSwitch.OnServerEvent:Connect(function(Player, Count, Blocking)
	if Blocking ~= true then
	
		Stances = Count
		print(Stances)
	StanceSwitching.Switches(Player, Count)	
	end
	
	if Blocking == true then
		BStances = Count
		print(BStances)
		StanceSwitching.BlockSwitches(Player, Count)
	end
end)

–Block Switches

function StanceSwitch.BlockSwitches(Player, Count)
	if Count == 1 then
		Player:SetAttribute("BStance", BlockStances[1])

	
	elseif Count == 2 then
		Player:SetAttribute("BStance", BlockStances[2])

		
	elseif Count == 3 then
		
		Player:SetAttribute("BStance", BlockStances[3])

		
	end
end

And the local script is for the animation
This is in the server currently, and what would happen if I linked it up to this

UserInputService.InputBegan:Connect(function(Input, GPE)
	
	if GPE then return end
	
	if Debounce == true then return end

	if Input.KeyCode == Enum.KeyCode.T and UserInputService:IsKeyDown(Enum.KeyCode.F) then
		if Debounce == false then 
			if BlockingBoppin.Parent == Players.LocalPlayer.Character.Head then
				Debounce = true
				BlockingBoppin.Star:Emit(1)
				BlockingBoppin.Circle:Emit(1)
				BlockingBoppin.StarAfterImage:Emit(1)
				BlockingBoppin.CircleAfterImage:Emit(1)

				BlockCountChanger()

				Stances:FireServer(BCount, true)

				task.wait(5)

				Debounce = false
			elseif BlockingBoppin.Parent ~= Players.LocalPlayer.Character.Head then
				Debounce = true
				BlockingBoppin.Parent = Players.LocalPlayer.Character.Head

				BlockingBoppin.Star:Emit(1)
				BlockingBoppin.Circle:Emit(1)
				BlockingBoppin.StarAfterImage:Emit(1)
				BlockingBoppin.CircleAfterImage:Emit(1)

				BlockCountChanger()
			
				Stances:FireServer(BCount, true)
				task.wait(5)

				Debounce = false
				end			
		end
	end
end)

sorry if it’s packed on your screen, but to fully understand I believe you need these 4 sections of the scripts.

Did you need more?

ah 30 mannnn

Fixed it up myself. Thank you for the assistance.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.