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

How do i random animation punch?

Asked by 5 years ago

How do i make punch random animation?

Here the code

local player = game.Players.LocalPlayer
local db = true
local db2 = false
local damage = false

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

game.Players.LocalPlayer.Character:WaitForChild("RightHand").Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and db2 and hit.Parent.Humanoid ~= game.Players.LocalPlayer.Character.Humanoid then
        if game.Players.LocalPlayer.Character.Humanoid.Health > 0 then
            game.ReplicatedStorage.Punch:FireServer(hit.Parent.Humanoid)
        end
    end
end)

game:GetService("UserInputService").InputBegan:Connect(function(input, event)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        db = false
    db2 = true
    wait(.5)
    db2 = false
        local playAnim = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):loadAnimation(anim)
        playAnim:Play()
        wait(4.5)
        damage = false
        db = true


    end
end)

1 answer

Log in to vote
0
Answered by
iuclds 720 Moderation Voter
5 years ago
AnimationTable = {"123","1234"}

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

local db2 = false
local damage = false

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://"..(math.random(1, #AnimationTable))

game.Players.LocalPlayer.Character:WaitForChild("RightHand").Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and db2 and hit.Parent.Humanoid ~= game.Players.LocalPlayer.Character.Humanoid then
        if game.Players.LocalPlayer.Character.Humanoid.Health > 0 then
            game.ReplicatedStorage.Punch:FireServer(hit.Parent.Humanoid)
        end
    end
end)

game:GetService("UserInputService").InputBegan:Connect(function(input, event)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        db = false
    db2 = true
    wait(.5)
    db2 = false
        local playAnim = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):loadAnimation(anim)
        playAnim:Play()
        wait(4.5)
        damage = false
        db = true


    end
end)

i love you good sir

0
okay papa and thanks you papa OrewaKamidaa 40 — 5y
0
10 anim.AnimationId = "rbxassetid://"..(math.random(1, #AnimationTable)) OrewaKamidaa 40 — 5y
0
do i need to add both animation? and what is it code OrewaKamidaa 40 — 5y
Ad

Answer this question