Equip Event not working

For some reason my equip sound for my tool is not working. Theres a remote event located inside of a folder within the tool which i don’t think is being fired upon the tool being equipped.

Here is a part of the script if anybody knows what is going wrong. Any help is appreciated.

equipEvent.OnServerEvent:Connect(function(player, val)
	if val == "Equip" then
		sheathSound:Play()
	elseif val == "Unequip" then
		slashSound:Stop()
		sheathSound:Stop()
		unsheathSound:Stop()
	end
end)
4 Likes

Can’t you just listen to the Tool.Equipped and Tool.Unequipped events?

4 Likes

Nothing looks off with this part, but it hard to say without seeing the whole script.

Also you say the equip sounds arent working, are the unequip sounds working?

3 Likes

The only sound that works is the slashsound none of the other sounds work for some reason. Here is the full script.

local RaycastHitbox = require(script.Parent.RaycastHitboxV4)
local Tool = script.Parent.Parent

local equipEvent = Tool.Events:WaitForChild("Equip")
local attackEvent = Tool.Events:WaitForChild("Attack")
local returnEvent = Tool.Events:WaitForChild("ReturnData")

local slashSound = Tool.Sounds:WaitForChild("SwordSlash")
local sheathSound = Tool.Sounds:WaitForChild("sheath")
local unsheathSound = Tool.Sounds:WaitForChild("Unsheath")
local hitSound = Tool.Sounds:WaitForChild("hitSound")

local function check(char)
	for i, v in ipairs(char:GetChildren()) do
		if v:IsA("Tool") and Tool == v then
			return true
		end
	end
end

--The index is the reference which is the randomly chosen number, the first value in the table is the animation length
local animationIndex = {
	["1"] = 1,
	["2"] = 1,
	["3"] = 1,
	["4"] = 1,
	["5"] = 1
}

function OnActivation(player)
	local chosenNum = tostring(math.random(1,5))
	returnEvent:FireClient(player, chosenNum)
	
	if check(player.Character) then
		Tool.Handle.Trail.Enabled = true
		--task.wait("x amoutn of time") this is so that the sound of the slash is linked up with the slash animation
		
		if check(player.Character) then
			slashSound:Play()
			task.wait(animationIndex[chosenNum])
			Tool.Handle.Trail.Enabled = false
		end
	end

end

local db = false
attackEvent.OnServerEvent:Connect(function(player)
	if db == false then
		db = true
		OnActivation(player)
		task.wait(0.4)
		db = false
	end
end)

equipEvent.OnServerEvent:Connect(function(player, val)
	if val == "Equip" then
		sheathSound:Play()
	elseif val == "Unequip" then
		slashSound:Stop()
		sheathSound:Stop()
		unsheathSound:Stop()
	end
end)

2 Likes

Ok and u’ve checked that the sounds are:

  1. located where they should be in the tool in Sounds.
  2. that the sounds are private now, since they are longer than 6 seconds.
2 Likes

Yep. Everything is properly placed inside of the tool. The sounds are all mine and none of them exceed 6 seconds.

2 Likes

No where in that script is it calling for the other sounds to play… only the slashSound in the OnActivation function.

This calls for the sounds to stop, but not play.

2 Likes

I thought

equipEvent.OnServerEvent:Connect(function(player, val)
	if val == "Equip" then
		sheathSound:Play()

was calling for the sound to play? How would i call for all the sounds to play?

2 Likes

Yes that calls for the sheath sound to play… to add the others just add them under:
slashSound:Play()
unsheathSound:Play()

2 Likes

Still not working. Quick question. Since im not the one who wrote the script. Is “if val” referring to a value that is supposed to be somewhere

2 Likes

It refers to a remote event which fires to the server when the client equips or unequips the tool.

2 Likes

Try to play sounds in local script

1 Like