I’m trying to add sounds to a stand I have and I can’t figure out what I spefically want it to do because it is not like the other ones
I want to add a full sound but make it pause after every punch.
The way the combat system works is it starts L (first punch) goes to LL (Second) and LLL (Third) and I want to add a sound for each hit in the combat sequence
Can anyone help me? this is the localscript and serverscript for punching
Server Script
local rp = game:GetService("ReplicatedStorage")
local Punch = rp:WaitForChild("Punch")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local Animations = script:WaitForChild("Animations")
local Meshes = script:WaitForChild("Meshes")
local SSS = game:GetService("ServerScriptService")
local Library = SSS:WaitForChild("Library")
local DictionaryHandler = require(Library:WaitForChild("DictonaryHandler"))
local Damage = 7.5
local plrsHit = {}
local R15 =
{
["L"] = Animations.R15.Combat1,
["LL"] = Animations.R15.Combat2,
["LLL"] = Animations.R15.Combat3,
}
local R6 =
{
["L"] = Animations.R6.Combat1,
["LL"] = Animations.R6.Combat2,
["LLL"] = Animations.R6.Combat3,
}
function doDamage(Character,humrp,Folder)
local Hitbox = Meshes:WaitForChild("Hitbox"):Clone()
Hitbox.CFrame = humrp.CFrame * CFrame.new(0,0,-2)
Hitbox.Parent = Folder
local weld = Instance.new("ManualWeld")
weld.Part0 = Hitbox
weld.Part1 = humrp
weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
weld.Parent = weld.Part0
Hitbox.Touched:Connect(function(Hit)
if Hit:IsA("BasePart") then
if not Hit:IsDescendantOf(Character) then
local enemyHum = Hit.Parent:FindFirstChild("Humanoid")
local enemyHumRP = Hit.Parent:FindFirstChild("HumanoidRootPart")
if enemyHum and enemyHumRP then
if not DictionaryHandler.findPlayer(enemyHum,"Blocking") then
--/If the enemy is blocking
Hitbox:Destroy()
enemyHum:TakeDamage(Damage)
if not plrsHit[enemyHum] then
DictionaryHandler.addTo(enemyHum,"Stunned")
plrsHit[enemyHum] = 1.2
enemyHum.WalkSpeed = 6
enemyHum.JumpPower = 0
while wait(1) do
if plrsHit[enemyHum] > 0 then
plrsHit[enemyHum] -= 1
else
plrsHit[enemyHum] = nil
DictionaryHandler.removeFrom(enemyHum,"Stunned")
enemyHum.WalkSpeed = 16
enemyHum.JumpPower = 50
break
end
end
elseif plrsHit[enemyHum] then
plrsHit[enemyHum] = 1.2
enemyHum.WalkSpeed = 6
enemyHum.JumpPower = 0
end
else
--/If the enemy is blocking
Hitbox:Destroy()
end
end
end
end
end)
end
Punch.OnServerEvent:Connect(function(Player,comSeq)
local Character = Player.Character
local Humanoid = Character.Humanoid
local HumanoidRP = Character.HumanoidRootPart
if not DictionaryHandler.findPlayer(Humanoid,"Stunned") and not DictionaryHandler.findPlayer(Humanoid,"Blocking") and not DictionaryHandler.findPlayer(Humanoid,"Barraging") then
--if player is not stunned or blocking or Barraging
local Stand = Character:FindFirstChild("Stand")
if Stand then
--if stand is found
local AnimControl = Stand:FindFirstChild("AnimControl")
if AnimControl then
local Controller = Stand.PrimaryPart:FindFirstChild("Controller")
if Controller then
local goal = {}
goal.C0 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame)
goal.C1 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame * CFrame.new(0,0.25,-3))
local info = TweenInfo.new(.1)
local Tween = TweenService:Create(Controller,info,goal)
Tween:Play()
--/Animation to be played
local Action
local HumanoidType = AnimControl:FindFirstChild("HumanoidType")
if HumanoidType.Value == "R15" then
Action = AnimControl:LoadAnimation(R15[comSeq])
elseif HumanoidType.Value == "R6" then
Action = AnimControl:LoadAnimation(R6[comSeq])
end
Action:Play()
DictionaryHandler.addTo(Humanoid,"Punching")
local Folder = Instance.new("Folder",workspace)
Folder.Name = "Effects"
Debris:AddItem(Folder,.5)
local stand_Humrp = Stand:FindFirstChild("HumanoidRootPart")
--/Do Damage Function
doDamage(Character,stand_Humrp,Folder)
Action.Stopped:Connect(function()
spawn(function()
wait(.1)
local goal = {}
goal.C0 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame)
goal.C1 = Controller.Part0.CFrame:ToObjectSpace(Controller.Part1.CFrame * CFrame.new(-3,1,2))
local info = TweenInfo.new(.1)
local Tween = TweenService:Create(Controller,info,goal)
Tween:Play()
end)
Punch:FireClient(Player, true)
wait(0.3)
DictionaryHandler.removeFrom(Humanoid,"Punching")
end)
end
end
else
--if stand is not found
Punch:FireClient(Player, false)
end
else
Punch:FireClient(Player, false)
end
end)
Local Script
local Player = game:GetService("Players").LocalPlayer
local rp = game:GetService("ReplicatedStorage")
local Punch = rp:WaitForChild("Punch")
local UIS = game:GetService("UserInputService")
local debounce = false
local comSeq = ""
local currTime = 0
local prevTime = 0
local cds =
{
cd1 = .1;
cd2 = 2;
}
UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then
return
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
if debounce == false then
debounce = true
currTime = os.clock()
local passTime = currTime - prevTime
if passTime < 1 then
comSeq = comSeq.."L"
if string.len(comSeq) > 3 then
comSeq = "L"
end
else
comSeq = "L"
end
Punch:FireServer(comSeq)
end
end
end)
Punch.OnClientEvent:Connect(function(canPunch)
if canPunch then
--Player has Stand Equipped
prevTime = currTime
wait(cds.cd1)
debounce = false
else
--Player doesn't have Stand Equipped
wait(cds.cd2)
debounce = false
end
end)