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

I want to play animation one by one?

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)

4 comments

0

make a list, then use wait(1) to search through each interval of the list.

0

like this

0

can you please answer what are you talking about?

0

can you please put your answer in the answer box so that i can understand

1 answer

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)

1 comment

0

might have to add some waits

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