So I am making a punch tool and wanted to know how to make a randomized punch sound. so If the hitbox hits the other player it plays a random punch sound from a folder inside the handle. How can I do this? this is the script:
local Player = script.Parent.Parent.Parent
local Character = Player.Character
local RaycastHitbox = require(game.ServerScriptService.RaycastHitboxV2)
local ShockWave = require(game.ServerScriptService.Modules.Visualiser.Modules.ShockWave)
local Hitbox = RaycastHitbox:Initialize(script.Parent.Handle)
local DB = false
Hitbox.OnHit:Connect(function(hit, humanoid)
if humanoid.Parent ~= Character then
local damage = math.random(5,10)
local Speed = 25
local Force = 40000
local TotalForce = Force
local KnockBack = Instance.new("BodyVelocity",hit.Parent:FindFirstChild("Torso"))
ShockWave.MakePart(hit.Position)
KnockBack.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)
KnockBack.Velocity = Player.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * Speed
game.Debris:AddItem(KnockBack,0.1)
spawn(function()
humanoid.PlatformStand = true
wait(3)
humanoid.PlatformStand = false
end)
humanoid:TakeDamage(damage)
end
end)