Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i add sounds to this weapon?

Asked by 3 years ago

i want to add swing and hit sound to my weapon script and i dont know how tho. :(

heres the script

local tool = script.Parent

local canDamage = false

local Cooldown = false

local WaitTime: number = 0.3 --// anything

local function onTouch(otherPart)
    local humanoid = otherPart.Parent:FindFirstChild("Humanoid")

    if not humanoid then return end

    if humanoid.Parent ~= tool.Parent and canDamage then 
        humanoid:TakeDamage(15)
    else
        return
    end

    canDamage = false
end

local function slash()
    if Cooldown then return end
    Cooldown = true

    local str = Instance.new("StringValue")

    str.Name = "e" --idk why i made it e, i just edited the script that i used for an old game
    str.Value = "Slash"
    str.Parent = tool

    canDamage = true

    wait(WaitTime)

    Cooldown = false
end

tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)
0
also an equip if ya can steel_apples 58 — 3y
1
https://developer.roblox.com/en-us/api-reference/class/Sound note this and other situations using sound with script. TerranRecon 49 — 3y

Answer this question