Help to create wait

hello i create script help me to wait my script

local IdleAnim = Instance.new("Animation")
IdleAnim.AnimationId = "rbxassetid://14813772308"
local firstTrack 
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://13383682135"
local track
local character

tool.Equipped:Connect(function()
	firstTrack = script.Parent.Parent.Humanoid:LoadAnimation(IdleAnim)
	firstTrack.Priority = Enum.AnimationPriority.Action
	firstTrack.Looped = false
	firstTrack:Play()
	character = tool.Parent
	character.Humanoid.WalkSpeed = 0
	character.Humanoid.JumpPower = 0
	wait(1)
end)

tool.Activated:Connect(function()
	track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
	track.Priority = Enum.AnimationPriority.Action
	track.Looped = false
	track:Play()
	wait(1)
end)

tool.Unequipped:Connect(function()
	if firstTrack then
		firstTrack:Stop()
		character.Humanoid.WalkSpeed = 16 -- the default speed
		character.Humanoid.JumpPower = 50 -- the default jump power
	end
end)

tool.Unequipped:Connect(function()
	if track then
		track:Stop()
		character.Humanoid.WalkSpeed = 16 -- the default speed
		character.Humanoid.JumpPower = 50 -- the default jump power
	end
end)

I want to add a Wait but I don’t know where to write it

local Debounce = false
local IdleAnim = Instance.new("Animation")
IdleAnim.AnimationId = "rbxassetid://14813772308"
local firstTrack 
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://13383682135"
local track
local character

tool.Equipped:Connect(function()
	firstTrack = script.Parent.Parent.Humanoid:LoadAnimation(IdleAnim)
	firstTrack.Priority = Enum.AnimationPriority.Action
	firstTrack.Looped = false
	firstTrack:Play()
	character = tool.Parent
	character.Humanoid.WalkSpeed = 0
	character.Humanoid.JumpPower = 0
	wait(1)
end)

tool.Activated:Connect(function()
	if not Debounce then
		Debounce = true
		track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
		track.Priority = Enum.AnimationPriority.Action
		track.Looped = false
		track:Play()
		wait(1)
		Debounce = false
		
	end
end)

tool.Unequipped:Connect(function()
	if firstTrack then
		firstTrack:Stop()
		character.Humanoid.WalkSpeed = 16 -- the default speed
		character.Humanoid.JumpPower = 50 -- the default jump power
	end
end)

tool.Unequipped:Connect(function()
	if track then
		track:Stop()
		character.Humanoid.WalkSpeed = 16 -- the default speed
		character.Humanoid.JumpPower = 50 -- the default jump power
	end
end)

i added a Debounce to the Activated event, is that what you wanted?

1 Like

15:38:15.551 Players.Lamino961.Backpack.PushUp.Anim:10: attempt to index nil with ‘Equipped’ - Client - Anim:10

of course, you didn’t create a variable for the tool. “tool” is then unknown here

will you help me fix what I call Push-ups

if your script is inside the tool, directly a child of the tool the you can write it like this:

local tool = script.Parent

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.