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

How do i make my punch-script make damage when it touches someone? [....hello....]

Asked by 4 years ago
Edited 4 years ago

So to expand, i created a script that whenever you press on this tool, it fires an animation and takes damage on another player that got punched.

The error is that is it's not damaging me at all.

I know it's badly formatted, but I'm trying my best, and whats optimal for you guys.

The Local Script:

local Animation = script.Animation
local Replicated = game:GetService("ReplicatedStorage")
local RemoteEvent = Replicated.Remotes.Punch

local Debounce = false

wait(2)

local Humanoid = game.Players.LocalPlayer.Character.Humanoid

script.Parent.Activated:Connect(function()
    if not Debounce then
        Debounce = true

    local AnimationTrack = Humanoid:LoadAnimation(Animation)
    RemoteEvent:FireServer()
    wait(2)
    Debounce = false 
    end
end)

The Script:

local Tools = game:GetService("ReplicatedStorage"):WaitForChild("Tools")
local RemoteEvent = game:GetService("ReplicatedStorage").Remotes.Punch
local Animation = Tools.SuperPunch.PunchConnecter.Animation

wait(1)

RemoteEvent.OnServerEvent:Connect(function(player)
    local Hum = player.Character.Humanoid
    local AnimationTrack = Hum:LoadAnimation(Animation)
    AnimationTrack:Play()
    print("Hello!")

    if AnimationTrack.IsPlaying then
        local LeftArm = player.Character["RightHand"]

        LeftArm.Touched:Connect(function(hit)
            if hit.Parent:FindFirstChild("Humanoid") and game.Workspace:FindFirstChild(hit.Parent) then
                Hum:TakeDamage(0)
                if hit.Parent:FindFirstChild("Humanoid") and not game.Workspace:FindFirstChild(hit.Parent) then
                    Hum:TakeDamage(20)
                    Hum.Sit = true


    end
    end
    end)
        end
        end)
0
What is it doing? Not doing damage? or is there an error? Kblow1 53 — 4y
0
It's not doing damage maxpax2009 340 — 4y

Answer this question