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

I also have the starter character local script and this might not be working?

Asked by
jlc272 4
4 years ago

Script: local player = game.Players.LocalPlayer local db = true local damaged = false

local anim = Instance.new("Animation") anim.AnimationId = "http://www.roblox.com/asset/?id=4556329390"

game.players.localplayer.Character:waitforchild("righthand").touched:connect(function(hit) if hit.parent:findfirstchild("humanoid")and not db and not damaged and hit.parent.humanoid ~= game.Players.localplayer.character.humanoid then if game.Players.localplayer.character.humanoid.health > 0 then damaged = true game.ReplicatedStorage.Punch:FireServer(hit.parent.humanoid) end end end)

game:GetService("UserInputService").inputbegan:connect(function(input, event) if input.keycode == Enum.KeyCode.F and db then db = false local playanim = game.Players.LocalPlayer.Character:waitforchild("humanoid"):loadanimation(anim) playanim:play() wait(0.8) damaged = false db = true end end)

1 answer

Log in to vote
0
Answered by 4 years ago

Try this:

local player = game.Players.LocalPlayer 
local db = true 
local damaged = false

local anim = Instance.new("Animation") 
anim.AnimationId = "http://www.roblox.com/asset/?id=4556329390"

player.Character:WaitForChild("RightHand").Touched:Connect(function(hit) 
    local hitHumanoid = hit.Parent and hit.Parent:FindFirstChildOfClass("Humanoid")
    local playerHumanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid")


    if hitHumanoid and playerHumanoid and not db and not damaged and hitHumanoid ~= playerHumanoid and playerHumanoid.Health > 0 then 
        damaged = true 
        game.ReplicatedStorage.Punch:FireServer(hitHumanoid)
    end 
end)

game:GetService("UserInputService").InputBegan:Connect(function(input, event) 
    local playerHumanoid = player.Character and player.Character:FindFirstChildOfClass("Humanoid")

    if input.keycode == Enum.KeyCode.F and db and playerHumanoid then 
        db = false 
        local playanim = playerHumanoid:LoadAnimation(anim) 
        playanim:play() 
        wait(0.8) 
        damaged = false 
        db = true 
    end 
end)
0
Thanks! jlc272 4 — 4y
0
It didn't work for me but its probally just my problem jlc272 4 — 4y
Ad

Answer this question