My Remote Event Can't Change Value

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a remote event that can be Fired from the client and when it is Fired, it changes a NumberValue.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that my script doesn’t work.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I couldn’t find any solution.

Add Combo Remote Event:

-- Tool
local Tool = script.Parent.Parent

-- Values Folder
local ValuesFolder = Tool.Values

-- Remotes Folder
local RemotesFolder = Tool.Remotes

-- Add Combo Remote
local AddCombo = RemotesFolder.AddCombo

AddCombo.OnServerEvent:Connect(function(Player)
	ValuesFolder.Combo.Value += 1
end)

Local Script:

-- Attack
local Combo = Tool.Values.Combo

local function Attack()
	local Slash = humanoid:LoadAnimation(AnimFolder:WaitForChild("Slash" .. tostring(Combo.Value)))
	Slash:Play()
	
	Tool.Remotes.ClientCast:FireServer(Slash.Length, Config.Cooldown)
	canDamage = false
	SoundPlayer:FireServer(SoundParent:WaitForChild("Slash"))
	humanoid.WalkSpeed -= Config.WalkSpeed
	humanoid.JumpPower -= Config.JumpPower 
	task.wait(math.max(Slash.Length, Config.Cooldown))
	humanoid.WalkSpeed += Config.WalkSpeed
	humanoid.JumpPower += Config.JumpPower
	canDamage = true
end

UserInputService.InputBegan:Connect(function(input, gameProccessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and player.Character:FindFirstChild(Tool.Name) then
		if isAttacking == false and canDamage then
				isAttacking = true

				if Combo.Value > Config.MaxComboNumber then
					Combo.Value = 1
				end
			

				Attack()
				isAttacking = false
				AddCombo:FireServer()
		end
	end
end)

Put this part in Serverscriptstorage and see if it works:

local ValuesFolder = --put the location of the Values Folder
AddCombo.OnServerEvent:Connect(function(Player)
	ValuesFolder.Combo.Value += 1
end)

image
Client, can’t access ServerStorage, I think

yes put it in replicatedstorage instead.

It worked! But I’ve got another problem now.

-- Wait for char
game.Players.LocalPlayer.CharacterAdded:Wait()

-- Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local UserInputService = game:GetService("UserInputService")

-- Modules
local Config = require(script.Parent.Parent.Modules.Config)

-- Tool
local Tool = script.Parent.Parent
local Handle = Tool:WaitForChild("Handle")

-- UI
local UI = Tool.Assets.UI
local CooldownUI = UI.CooldownUI

-- Sword Vars
local Damage = Config.Damage
local Cooldown = Config.Cooldown

-- Player Vars
local player, humanoid, char
player = Players.LocalPlayer
humanoid = player.Character:WaitForChild("Humanoid")

-- Anim Folder
local AnimFolder = Tool.Animations

-- Remotes Folder
local RemotesFolder = Tool.Remotes

-- Remotes 
local SoundPlayer = RemotesFolder.SoundPlayer
local AddCombo = RemotesFolder.AddCombo
local ResetCombo = RemotesFolder.ResetCombo

-- Sounds Folder
local SoundParent = Tool.Handle

-- Booleans
local isAttacking = false
local canDamage = true

local function onEquip()
	local EquipAnim = AnimFolder:WaitForChild("Equip")
	local EquipTrack = humanoid:LoadAnimation(EquipAnim)
	EquipTrack:Play()
	SoundPlayer:FireServer(SoundParent:WaitForChild("Equip"))
end

local function onUnequip()
	local UnequipAnim = AnimFolder:WaitForChild("Unequip")
	local UnequipTrack = humanoid:LoadAnimation(UnequipAnim)
	UnequipTrack:Play()
	SoundPlayer:FireServer(SoundParent:WaitForChild("Unequip"))
end

-- Attack
local Combo = ReplicatedStorage.ASCS.Values.Combo

local function Attack()
	local Slash = humanoid:LoadAnimation(AnimFolder:WaitForChild("Slash" .. tostring(Combo.Value)))
	Slash:Play()
	
	Tool.Remotes.ClientCast:FireServer(Slash.Length, Config.Cooldown)
	canDamage = false
	SoundPlayer:FireServer(SoundParent:WaitForChild("Slash"))
	humanoid.WalkSpeed -= Config.WalkSpeed
	humanoid.JumpPower -= Config.JumpPower 
	task.wait(math.max(Slash.Length, Config.Cooldown))
	humanoid.WalkSpeed += Config.WalkSpeed
	humanoid.JumpPower += Config.JumpPower
	canDamage = true
end

UserInputService.InputBegan:Connect(function(input, gameProccessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and player.Character:FindFirstChild(Tool.Name) then
		if isAttacking == false and canDamage then
				isAttacking = true

				if Combo.Value > Config.MaxComboNumber then
					ResetCombo:FireServer()
				end
			

				Attack()
				isAttacking = false
				AddCombo:FireServer()
		end
	end
end)

Tool.Equipped:Connect(onEquip)
Tool.Unequipped:Connect(onUnequip)

image

try

local Slash = humanoid:LoadAnimation(AnimFolder:FindFirstChild("Slash" .. tostring(Combo.Value)))

There is no Slash6 though. I have set the MaxCombo to 5, not 6

I don’t think “FindFirstChild” should work. The issue is that the system tries to find a Slash6 animation, but there isn’t. And, actually it should try to find for Slash1 when Slash5 is finished because I do “ResetCombo:FireServer()”

I use FireServer, because I want to check the combo on the Server Script too.

yes i need to see the server sided script that is connected to AddCombo:FireServer()

-- Tool
local Tool = script.Parent.Parent

-- Values Folder
local ValuesFolder = game.ReplicatedStorage.ASCS.Values

-- Remotes Folder
local RemotesFolder = Tool.Remotes

-- Remotes
local AddCombo = RemotesFolder.AddCombo
local ResetCombo = RemotesFolder.ResetCombo

AddCombo.OnServerEvent:Connect(function(Player)
	ValuesFolder.Combo.Value += 1
end)

ResetCombo.OnServerEvent:Connect(function(Player)
	ValuesFolder.Combo.Value = 1
end)

do this

AddCombo.OnServerEvent:Connect(function(Player)
if ValuesFolder.Combo.Value < 6 then
	ValuesFolder.Combo.Value += 1
else
ValuesFolder.Combo.Value = 1
end
end)

You should add an else to reset it, the other remote might not fire in time.

image

Client Script

-- Wait for char
game.Players.LocalPlayer.CharacterAdded:Wait()

-- Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local UserInputService = game:GetService("UserInputService")

-- Modules
local Config = require(script.Parent.Parent.Modules.Config)

-- Tool
local Tool = script.Parent.Parent
local Handle = Tool:WaitForChild("Handle")

-- UI
local UI = Tool.Assets.UI
local CooldownUI = UI.CooldownUI

-- Sword Vars
local Damage = Config.Damage
local Cooldown = Config.Cooldown

-- Player Vars
local player, humanoid, char
player = Players.LocalPlayer
humanoid = player.Character:WaitForChild("Humanoid")

-- Anim Folder
local AnimFolder = Tool.Animations

-- Remotes Folder
local RemotesFolder = Tool.Remotes

-- Remotes 
local SoundPlayer = RemotesFolder.SoundPlayer
local AddCombo = RemotesFolder.AddCombo

-- Sounds Folder
local SoundParent = Tool.Handle

-- Booleans
local isAttacking = false
local canDamage = true

local function onEquip()
	local EquipAnim = AnimFolder:WaitForChild("Equip")
	local EquipTrack = humanoid:LoadAnimation(EquipAnim)
	EquipTrack:Play()
	SoundPlayer:FireServer(SoundParent:WaitForChild("Equip"))
end

local function onUnequip()
	local UnequipAnim = AnimFolder:WaitForChild("Unequip")
	local UnequipTrack = humanoid:LoadAnimation(UnequipAnim)
	UnequipTrack:Play()
	SoundPlayer:FireServer(SoundParent:WaitForChild("Unequip"))
end

-- Attack
local Combo = ReplicatedStorage.ASCS.Values.Combo

local function Attack()
	local Slash = humanoid:LoadAnimation(AnimFolder:FindFirstChild("Slash" .. tostring(Combo.Value)))
	Slash:Play()
	
	Tool.Remotes.ClientCast:FireServer(Slash.Length, Config.Cooldown)
	canDamage = false
	SoundPlayer:FireServer(SoundParent:WaitForChild("Slash"))
	humanoid.WalkSpeed -= Config.WalkSpeed
	humanoid.JumpPower -= Config.JumpPower 
	task.wait(math.max(Slash.Length, Config.Cooldown))
	humanoid.WalkSpeed += Config.WalkSpeed
	humanoid.JumpPower += Config.JumpPower
	canDamage = true
end

UserInputService.InputBegan:Connect(function(input, gameProccessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 and player.Character:FindFirstChild(Tool.Name) then
		if isAttacking == false and canDamage then
				isAttacking = true

				Attack()
				isAttacking = false
				AddCombo:FireServer()
		end
	end
end)

Tool.Equipped:Connect(onEquip)
Tool.Unequipped:Connect(onUnequip)

Server Script

-- Tool
local Tool = script.Parent.Parent

-- Sound Folder
local SoundParent = Tool.Handle

-- Particle Folder 
local ParticleFolder = Tool.Particles

-- Modules
local ClientCast = require(game.ReplicatedStorage.ASCS.ClientCast)
local Config = require(Tool.Modules.Config)

-- ClientCast
local clientCasterParams = RaycastParams.new()
clientCasterParams.FilterType = Enum.RaycastFilterType.Blacklist
clientCasterParams.IgnoreWater = true
clientCasterParams.FilterDescendantsInstances = {Tool.Parent.Parent.Character}

local Caster = ClientCast.new(Tool.Handle, clientCasterParams)

local db = {}

local Combo = game.ReplicatedStorage.ASCS.Values.Combo

Tool.Remotes.ClientCast.OnServerEvent:Connect(function(plr, length, cooldown)
	local event = Caster.HumanoidCollided:Connect(function(result, hithumanoid)
		if db[hithumanoid] then return end

		db[hithumanoid] = true

		if Combo.Value ~= Config.MaxComboNumber then
			hithumanoid:TakeDamage(Config.Damage)
		else
			hithumanoid:TakeDamage(Config.LastDamage)
		end
		SoundParent:WaitForChild("Hit"):Play()
		
		-- Hit Effect
		if Config.R6 and not Config.R15 and Config.Effects then
			local Hit = ParticleFolder:FindFirstChild("Hit"):GetChildren()
			for i, v in pairs(Hit) do
				v.Enabled = true
			end
			local newHitParticle = ParticleFolder.Hit:Clone()
			newHitParticle.Parent = hithumanoid.Parent.Torso
			newHitParticle.Position = hithumanoid.Parent.Torso.Position
		elseif Config.R15 and not Config.R6 and Config.Effects then
			local Hit = ParticleFolder:FindFirstChild("Hit"):GetChildren()
			for i, v in pairs(Hit) do
				v.Enabled = true
			end
			local newHitParticle = ParticleFolder.Hit:Clone()
			newHitParticle.Parent = hithumanoid.Parent.UpperTorso
			newHitParticle.Position = hithumanoid.Parent.UpperTorso.Position
		end
		
		hithumanoid.WalkSpeed -= hithumanoid.WalkSpeed
		hithumanoid.JumpPower -= hithumanoid.JumpPower

		wait(.35)
		
		-- Hit Effect
		if Config.R6 and not Config.R15 and Config.Effects then
			hithumanoid.Parent.Torso:FindFirstChild("Hit"):Destroy()
			local Hit = ParticleFolder:FindFirstChild("Hit"):GetChildren()
			for i, v in pairs(Hit) do
				v.Enabled = false
			end
		elseif Config.R15 and not Config.R6 and Config.Effects then
			hithumanoid.Parent.UpperTorso:FindFirstChild("Hit"):Destroy()
			local Hit = ParticleFolder:FindFirstChild("Hit"):GetChildren()
			for i, v in pairs(Hit) do
				v.Enabled = false
			end
		end
		
		hithumanoid.WalkSpeed = Config.WalkSpeed
		hithumanoid.JumpPower = Config.JumpPower
		db[hithumanoid] = false
	end)
	
	Caster:Start()
	
	task.wait(math.max(length, cooldown))
	Caster:Stop()
	event:Disconnect()
end)

Combo Handler

-- Tool
local Tool = script.Parent.Parent

-- Values Folder
local ValuesFolder = game.ReplicatedStorage.ASCS.Values

-- Config
local Config = require(Tool.Modules.Config)

-- Remotes Folder
local RemotesFolder = Tool.Remotes

-- Remotes
local AddCombo = RemotesFolder.AddCombo

AddCombo.OnServerEvent:Connect(function(Player)
	if ValuesFolder.Combo.Value > Config.MaxComboNumber then
		ValuesFolder.Combo.Value = 1
	else
		ValuesFolder.Combo.Value += 1
	end
end)

I fixed it. It should be like this:

AddCombo.OnServerEvent:Connect(function(Player)
	if ValuesFolder.Combo.Value > Config.MaxComboNumber - 1 then
		ValuesFolder.Combo.Value = 1
	else
		ValuesFolder.Combo.Value += 1
	end
end)