Effects/Sounds not appearing/playing for other users

I am currently trying to make a Sword Fighting game, with an advanced combat system. I have run into a problem however, I of course want everyone to be able to see when someone slashes or uses a move in front of them, so that they can dodge or block it. However certain effects and sounds do not show up for other players, while others do. To be more specific, my “bigSlash” does not show or play its sound for others, and my “slash” only plays the effect, and not the sound. Does anyone know how I can make it so everyone does see and hear it? Here are my scripts.

Regular Script:

local remote = game.ReplicatedStorage.Remotes.Combat

remote.OnServerEvent:Connect(function(p,data)
	if data.action == "slash" then
		for i,player in pairs(game.Players:GetChildren()) do
			if player ~= p then
				remote:FireClient(player, data)
			end
		end
	elseif data.action == "hit" then
		remote:FireAllClients( data)
		for i,v in pairs(data.hb) do
			if v:FindFirstChild("Block") then
				if v.Block.Value == true then
					local parryAnim = Instance.new("Animation")
					parryAnim.AnimationId = data.parry
					v.Humanoid:LoadAnimation(parryAnim):Play()
					parryAnim:Destroy()
				else
					local hitAnim = Instance.new("Animation")
					hitAnim.AnimationId = data.hit
					v.Humanoid:LoadAnimation(hitAnim):Play()
					hitAnim:Destroy()
					v.Humanoid:TakeDamage(10)
				end
			else
				local hitAnim = Instance.new("Animation")
				hitAnim.AnimationId = data.hit
				v.Humanoid:LoadAnimation(hitAnim):Play()
				hitAnim:Destroy()
				v.Humanoid:TakeDamage(10)
			end
			

			local bv = Instance.new("BodyVelocity", v.PrimaryPart)
			bv.MaxForce = Vector3.new(99999,0,99999)
			bv.Name = "v"
			bv.P = 10
			game.Debris:AddItem(bv,.2)

			if data.combo == 5 then
				bv.Velocity = data.c.PrimaryPart.CFrame.LookVector * 50
			else
				bv.Velocity = data.c.PrimaryPart.CFrame.LookVector * 20
			end

			local bv = Instance.new("BodyVelocity",data.c.PrimaryPart)
			bv.MaxForce = Vector3.new(99999,0,99999)
			bv.Name = "v"
			bv.P = 10
			game.Debris:AddItem(bv,.2)
			if data.combo == 5 then
				bv.Velocity = data.c.PrimaryPart.CFrame.LookVector * 50
			else
				bv.Velocity = data.c.PrimaryPart.CFrame.LookVector * 20
			end 

			local stun = Instance.new("BoolValue", v)
			stun.Name = "Stun"
			stun.Value = false
			game.Debris:AddItem(stun,1)
		end
	elseif data.action == "block" then
		if data.char:FindFirstChild("Block") then
			data.char.Block.Value = true
		else
			local block = Instance.new("BoolValue", data.char)
			block.Value = true
			block.Name = "Block"
		end
	elseif data.action == "unblock" then
		if data.char:FindFirstChild("Block") then
			data.char.Block.Value = false
		elseif data.action == "bigSlash" then
			for i,player in pairs(game.Players:GetChildren()) do
				if player ~= p then
					remote:FireClient(player, data)
				end
			end
		end
	end
end)

LocalScript:

local swingAnims = {
	'rbxassetid://13712012221', --1
	'rbxassetid://13712015281', --2
	'rbxassetid://13712021768', --3
	'rbxassetid://13712025174', --4
	'rbxassetid://13712032363', --5
}

local textures = {
	'rbxassetid://8821230983', --1
	'rbxassetid://8821230983', --2
	'rbxassetid://8821246947', --3
	'rbxassetid://8821254467', --4
	'rbxassetid://8821272181', --5
	'rbxassetid://8821280832', --6
	'rbxassetid://8821300395', --7
	'rbxassetid://8821311218', --8
	'rbxassetid://8896641723', --9
}  

local blockAnims = {
	'rbxassetid://13712037405', -- idle blocking
	'rbxassetid://13712039831', -- parry
	'rbxassetid://13712043092', -- hit
}

local t = game:GetService("TweenService")
local rs = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")

local resources = rs.Combat.Sword
local fx = resources.Fx
local remote = rs.Remotes.Combat

local p = game.Players.LocalPlayer
local c = script.Parent
local hrp = c.HumanoidRootPart
local hu = c.Humanoid
local combo = 1
local lasthit = 0
local cd = false
local blocking = false

local anim = script:WaitForChild("Animation")

local function setUp(char)
	local handle = fx.Handle:Clone()
	handle.Parent = char
	local m6d = Instance.new("Motor6D", handle)
	m6d.Part0 = char.RightHand
	m6d.Part1 = handle
	m6d.C1 = CFrame.new(0,.125,0)
	local model = fx.MeshPart:Clone()
	model.Parent = workspace.Fx
	local weld = Instance.new("Weld", model)
	weld.Part0 = handle
	weld.Part1 = model
	weld.C1 = CFrame.new(0,-2.2,0) * CFrame.Angles(math.rad(90),0,0)
end

for i,v in pairs(game.Players:GetChildren()) do
	repeat wait() until v.Character
	setUp(v.Character)
	v.CharacterAdded:Connect(function(char)
		char:WaitForChild("RightHand")
		setUp(char)
	end)
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		char:WaitForChild("RightHand")
		setUp(char)
	end)
end)

local function slash(char, comboN)
	local m = fx.Slash:Clone()
	local hrp = char.HumanoidRootPart

	if comboN == 1 then
		wait(.2)
		m.CFrame = hrp.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0,math.rad(-30),math.rad(-240))
		t:Create(m, TweenInfo.new(.5), {CFrame = m.CFrame * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
	elseif comboN == 2 then
		wait(.2)
		m.CFrame = hrp.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0,math.rad(30),math.rad(0))
		t:Create(m, TweenInfo.new(.5), {CFrame = m.CFrame * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
	elseif comboN == 3 then
		wait(.3)
		m.CFrame = hrp.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0,math.rad(30),math.rad(-15))
		t:Create(m, TweenInfo.new(.5), {CFrame = m.CFrame * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
	elseif comboN == 4 then
		wait(.4)
		m.CFrame = hrp.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0,math.rad(30),math.rad(235))
		t:Create(m, TweenInfo.new(.5), {CFrame = m.CFrame * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
	elseif comboN == 5 then
		wait(.4)
		m.CFrame = hrp.CFrame * CFrame.new(0,0,-6) * CFrame.Angles(0,math.rad(30),math.rad(0))
		t:Create(m, TweenInfo.new(.5), {CFrame = hrp.CFrame * CFrame.new(0,0,-10) * CFrame.Angles(0,math.rad(-100),0), Transparency = 1}):Play()
	end
	t:Create(m.light, TweenInfo.new(.4), {Brightness = 0}):Play()
	game.Debris:AddItem(m, 1)
	
	local count = 1
	local connection
	connection = game["Run Service"].RenderStepped:Connect(function()
		m.Mesh.TextureId = textures[count]
		count = count + 1
		if count > #textures then
			count = 1
			connection:Disconnect()
		end
	end)

	m.Parent = workspace.Fx

	if char == c then
		local hb = Instance.new("Part", workspace.Fx)
		hb.Size = Vector3.new(10,3,7)
		hb.CFrame = hrp.CFrame * CFrame.new(0,0,-5)
		hb.Anchored = true
		hb.CanCollide = false
		hb.Transparency = .6
		hb.Name = "hb"
		hb.Material = Enum.Material.ForceField
		hb.CanQuery = false

		local con
		con = hb.Touched:Connect(function()
			con:Disconnect()
		end)

		local hits = {}
		for i,v in pairs(hb:GetTouchingParts()) do
			if v:IsDescendantOf(char) == false then
				if v.Parent:FindFirstChildWhichIsA("Humanoid") and table.find(hits, v.Parent) == nil then

					table.insert(hits, v.Parent)

				end
			end
		end

		if #hits == 0 then
			local bv = Instance.new("BodyVelocity",char.PrimaryPart)
			bv.MaxForce = Vector3.new(99999,0,99999)
			bv.Name = "v"
			bv.P = 10
			game.Debris:AddItem(bv,.2)
			if comboN == 5 then
				bv.Velocity = char.PrimaryPart.CFrame.LookVector * 50
			else
				bv.Velocity = char.PrimaryPart.CFrame.LookVector * 20
			end
		end

		local data = {hb = hits, action = "hit", combo = comboN, c = char, parry = blockAnims[2], hit = blockAnims[3]}
		remote:FireServer(data)

		hb:Destroy()
	end
end

local function slashBig(char)
	local m = fx.LargeSlash:Clone()
	local hrp = char.HumanoidRootPart
		m.CFrame = hrp.CFrame * CFrame.Angles(0,math.rad(math.random(0,180)),math.rad(math.random(-10,10)))
		t:Create(m, TweenInfo.new(.3), {CFrame = hrp.CFrame * CFrame.Angles(0,math.rad(-100),math.rad(math.random(-10,10))), Transparency = 1}):Play()
		t:Create(m.light, TweenInfo.new(.2), {Brightness = 0}):Play()
game.Debris:AddItem(m, 1)

	m.Parent = workspace.Fx

	if char == c then
		local hb = Instance.new("Part", workspace.Fx)
		hb.Size = Vector3.new(30,6,30)
		hb.CFrame = hrp.CFrame
		hb.Anchored = true
		hb.CanCollide = false
		hb.Transparency = .6
		hb.Name = "hb"
		hb.Material = Enum.Material.ForceField
		hb.CanQuery = false

		local con
		con = hb.Touched:Connect(function()
			con:Disconnect()
		end)

		local hits = {}
		for i,v in pairs(hb:GetTouchingParts()) do
			if v:IsDescendantOf(char) == false then
				if v.Parent:FindFirstChildWhichIsA("Humanoid") and table.find(hits, v.Parent) == nil then

					table.insert(hits, v.Parent)

				end
			end
		end

		local data = {hb = hits, action = "hit", combo = 1, c = char, parry = blockAnims[2], hit = blockAnims[3]}
		remote:FireServer(data)

		hb:Destroy()
	end
end

uis.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 and cd == false and c:FindFirstChild("Stun") == nil and blocking == false then

		c.Humanoid.WalkSpeed = 0
		c.Humanoid.JumpHeight = 0

		if tick() - lasthit > 1 then
			combo = 1
		end
		lasthit = tick()

		cd = true

		anim.AnimationId = swingAnims[combo]
		local load = c.Humanoid:LoadAnimation(anim):Play()
		game.ReplicatedStorage.Combat.Sword.Fx.Slash.Swing:Play()

		local data = {char = c, comboN = combo, action = "slash"}
		remote:FireServer(data)
		slash(c, combo)

		if combo == 5 then
			combo = 1
		else
			combo = combo + 1
		end
		wait(.1)

		cd = false

		c.Humanoid.WalkSpeed = 16
		c.Humanoid.JumpHeight = 7.2
	elseif input.UserInputType == Enum.UserInputType.MouseButton2 and cd == false and c:FindFirstChild("Stun") == nil and hu.WalkSpeed ~= 24 then
		anim.AnimationId = blockAnims[1]
		local load = c.Humanoid:LoadAnimation(anim)
		load:Play()
		blocking = true
		
		local data = {char = c, action = "block"}
		remote:FireServer(data)
		repeat
			wait()
		until blocking == false
		load:Stop()

elseif input.KeyCode == Enum.KeyCode.E and cd == false and c:FindFirstChild("Stun") == nil and blocking == false then
	cd = true
			anim.AnimationId = "rbxassetid://13712176316"
			local load = c.Humanoid:LoadAnimation(anim)
		load:Play()
		game.ReplicatedStorage.Combat.Sword.Fx.LargeSlash.Heavy:Play()
			wait(1)
			local data = {char = c, action = "bigSlash"}
			remote:FireServer(data)
			for i = 1, 5 do
				slashBig(c)
				wait()
			end
			cd = false
		end
	end)
	
uis.InputEnded:Connect(function(input, gpe)
	if input.UserInputType == Enum.UserInputType.MouseButton2 and blocking then
		blocking = false
		local data = {char = c, action = "unblock"}
		remote:FireServer(data)
	end
end)  

remote.OnClientEvent:Connect(function(data)
	if data.action == "slash" then
			slash(data.char, data.comboN)
		elseif data.action == "bigSlash" then
			slashBig(data.char)
			for i =1, 5 do
				slashBig(data.char)
				wait()
			end
	elseif data.action == "hit" then
		for i,v in pairs(data.hb) do
			if v:FindFirstChild("Block") then
				if v.Block.Value == true then
					local hit = fx.Block:Clone()
					hit.Anchored = false
					local weld = Instance.new("Weld", hit)
					weld.Part0 = v.PrimaryPart
					weld.Part1 = hit
					
					hit.Position = v.PrimaryPart.Position
					
					hit.Attachment.Hit:Emit(1)
					hit.Attachment.Vortex:Emit(10)
					hit.Attachment.Vortex2:Emit(10)
					hit.Attachment.vroom:Emit(2)
					
					hit.Parent = workspace.Fx
					hit.Clash:Play()
					game.Debris:AddItem(hit,2)
				else
					local hit = fx.Hit:Clone()
					hit.Anchored = false
					local weld = Instance.new("Weld", hit)
					weld.Part0 = v.PrimaryPart
					weld.Part1 = hit
					weld.C1 = weld.C1 * CFrame.Angles(0,0,math.rad(math.random(-300,300)))
					hit.Position = v.PrimaryPart.Position
					
					hit.Attachment.BloodHit:Emit(30)
					hit.Attachment.ParticleEmitter:Emit(10)
					hit.Attachment.ParticleEmitter2:Emit(10)
					
					hit.Parent = workspace.Fx
					hit.BloodHit:Play()
					game.Debris:AddItem(hit,2)
				end
			else
				local hit = fx.Hit:Clone()
				hit.Anchored = false
				local weld = Instance.new("Weld", hit)
				weld.Part0 = v.PrimaryPart
				weld.Part1 = hit
				weld.C1 = weld.C1 * CFrame.Angles(0,0,math.rad(math.random(-300,300)))
				hit.Position = v.PrimaryPart.Position

				hit.Attachment.BloodHit:Emit(30)
				hit.Attachment.ParticleEmitter:Emit(0)
				hit.Attachment.ParticleEmitter2:Emit(30)

				hit.Parent = workspace.Fx
				hit.BloodHit:Play()
				game.Debris:AddItem(hit,2)
			end
		end
	end
end)
1 Like

The slash sound is only played on the caster’s end, not to others, you have to manually replicate it for others to hear it.

For a more easier going (but more performant-costly) way is to handle the sound VFX on the server.

How would I do the 1st thing you said?

--client
doSound()
remote:FireServer()
remote.OnClientEvent:Connect(doReplicatedSound)

--server
remote.OnServerEvent:Connect(function(player)
   ...

   for _, other in ipairs(Players:GetPlayers()) do
      if other ~= player then
         remote: FireClient(other, tool.Position)
      end
   end
end)

I’m confused… How am I supposed to implement this script?

Scrap my replies above, I’ve rechecked your code and I saw that this line of code

game.ReplicatedStorage.Combat.Sword.Fx.LargeSlash.Heavy:Play()

is only played for the caster because it’s under uis.InputBegan:Connect()
to make it replicate for others and to yourself, you need to clone the sound and parent it to the player’s HumanoidRootPart.

local function playSound()
   local sound = someSound:Clone()
   sound.Parent = humanoidRootPart
   sound:Play()
   Debris:AddItem(sound, sound.TimeLength+0.01)
end
-- implement this code inside the uis.InputBegan and slash/slashBig functions