Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Im trying to make a punch animation. I dont know what im doing wrong but it wont work?

I have tried on various different days and dont know whats wrong. Script: game.players.playeradded:connect(function(player) player.characteradded:connect(function(char) local sound = game.ServerStorage.Punch:Clone() sound.parent = char:waitforchild("head") end) end)

game.ReplicatedStorage.Punch.OnServerEvent:Connect(function(player, humanoid) if humanoid.health >= 10 then humanoid.health = humanoid.health - 10 elseif humanoid.health < 10 then humanoid.health = 0 end

player.character.head.punch:play()

end)

1 answer

✓ Accepted answer

Try this:

game.Players.PlayerAdded:connect(function(player) 
    player.CharacterAdded:connect(function(char) 
        local sound = game.ServerStorage.Punch:Clone() 
        sound.parent = char:WaitForChild("Head")
    end) 
end)

game.ReplicatedStorage.Punch.OnServerEvent:Connect(function(player, humanoid) 
    if humanoid.health >= 10 then 
        humanoid.health = humanoid.health - 10 
    elseif humanoid.health < 10 then 
        humanoid.health = 0 
    end

    player.Character.Head.punch:play()
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.