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)
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)