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

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

Asked by
jlc272 4
4 years ago

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

Log in to vote
0
Answered by 4 years ago

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)
Ad

Answer this question