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

I want to play animation one by one?

Asked by 6 years ago
Edited 6 years ago

i want to change the local picked.

local picked = math.Random(1,animations)

not random. like i want the animation to play one by one.

this is the whole ServerScript.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = Instance.new("RemoteEvent", ReplicatedStorage)
punchEvent.Name = "PunchEvent"

local animations = {1741614100,1741629151,1744881048}

local function onPunchFired(plr)
    local part = Instance.new("Part")
    part.Transparency = 0
    local char = game.Workspace:FindFirstChild(plr.Name)
    local humanoid = char.Humanoid
    local animation = Instance.new("Animation")
    local picked = --Here
    animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked]
    local animTrack = humanoid:LoadAnimation(animation)
    animTrack:Play()
    local dmgScript = script.DmgScript:Clone()
    if picked == 1 then
        dmgScript.Parent = char.RightLowerArm
    elseif picked == 2 then
        dmgScript.Parent = char.LeftLowerArm
    elseif picked == 2 then
        dmgScript.Parent = char.RightLowerArm
    end
    dmgScript.Disabled = false
    wait(0.01)
    dmgScript:Destroy()
end


punchEvent.OnServerEvent:Connect(onPunchFired)
0
make a list, then use wait(1) to search through each interval of the list. DeceptiveCaster 3761 — 6y
0
like this OniSanYamate -17 — 6y
0
can you please answer what are you talking about? OniSanYamate -17 — 6y
0
can you please put your answer in the answer box so that i can understand OniSanYamate -17 — 6y

1 answer

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = Instance.new("RemoteEvent", ReplicatedStorage)
punchEvent.Name = "PunchEvent"

local animations = {1741614100,1741629151,1744881048}

local function onPunchFired(plr)
    local part = Instance.new("Part")
    part.Transparency = 0
    local char = game.Workspace:FindFirstChild(plr.Name)
    local humanoid = char.Humanoid
    local animation = Instance.new("Animation")
    local picked = --Here
    animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked]
    local animTrack = humanoid:LoadAnimation(animation)
    animTrack:Play()
    punchSequence()
end

local last = nil 
local pickedarm = nil 

local dmgenabled = false -- don't touch
local damage = 10

function punchSequence()
    dmgenabled = true 
    if not (last == char.RightLowerArm.Name) then 
        last = char.RightLowerArm.Name
        pickedarm = char.RightLowerArm
        print(pickedarm.Name)

    elseif not (last == char.LeftLowerArm.Name) and (last == char.RightLowerArm.Name) then 
        last = char.LeftLowerArm.Name
        pickedarm = char.LeftLowerArm
        print(pickedarm.Name)
    end

    pickedarm.Touched:connect(applyDamage)
end

function applyDamage(hit)
    if hit and dmgenabled then 
        if hit.Parent:FindFirstChild('Humanoid') then 
            local humanoid = hit.Parent:FindFirstChild('Humanoid')
            humanoid:TakeDamage(damage)
            dmgenabled = false 
        end
    end
end

punchEvent.OnServerEvent:Connect(onPunchFired)

0
might have to add some waits hellmatic 1523 — 6y
Ad

Answer this question