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

The sword script does not do damage when Slashing? [closed]

Asked by 4 years ago
Edited 4 years ago
local r = game:GetService("ReplicatedStorage"):WaitForChild("Sword")

r.OnServerEvent:Connect(function(Player, val)
    local character = workspace:WaitForChild(Player.Name)

    if val == "Slash" then

        local a = Instance.new("Animation", character)
        a.Name = ("Slash")
        a.AnimationId = "rbxassetid://5713765649"

        local a1 =  character:WaitForChild("Humanoid"):LoadAnimation(a)
        a1:Play()



        ----- damage and recognize scripts

        local findTool = character:FindFirstChild("Sword")
        if findTool then
            findTool.Blade.Touched:Connect(function(hit)
                if hit.Parent:FindFirstChild("Humanoid") then
                    local hum = hit.Parent:FindFirstChild("Humanoid")

                    if hum.Parent.Name ~= Player.Name and not hit.Parent:FindFirstChild("AlreadyHit") then
                        local f = Instance.new("IntValue", hum.Parent)
                        f.name = "AlreadyHit"
                        game.Debris:AddItem(f,5)
                        hum:TakeDamage(math.random(100,100))
                        wait(1)
                        hum.WalkSpeed = 15
                        hum.JumpPower = 50
                    end



                end 

        end)


        end
        wait(1)
        a1:Stop()
        a:Destroy()
    end
    end)

Closed as Non-Descriptive by JesseSong

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?