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

So basically this should do punches. But it don't.Could someone please correct it?

local player = game.Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

local right = Instance.new("Animation")

local left = Instance.new("Animation")

right.AnimationId = "http://www.roblox.com/Asset?ID=2984842184"

left.AnimationId = "http://www.roblox.com/Asset?ID=2984913037"

enable = false

Mouse = game.Players.LocalPlayer:GetMouse()

enable = false

Mouse.KeyDown:Connect(function(Key)

if Key == "e" then

local anim = character:LoadAnimation(right)

if enable == false then

anim:Play()

wait(0.2)

else

print('test')

end

if Key =='q' then

local anim = character:LoadAnimation(left)

if enable == false then

anim:Play()

wait(0.2)

else

print('test')

end

end

end

end)

1 answer

I tested the script and here are the problems:

  • The quotation marks that you put are not the correct ones. It's this: ", not this “”.
  • You can load animations into the Humanoid of a character, not the character itself. So it's not character:LoadAnimation(left), but character:WaitForChild("Humanoid"):LoadAnimation(left).
  • Add an "elseif" instead of an "if" in Line 37 and remove the last end), then put a ) at the last end.

I hope I helped somehow.

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