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

How do i give the player an animation when for example, pressed the C key?

Asked by 6 years ago

For example, when you press C the player will be given an long jump animation i have a few issues with this script, HERE IS THE SCRIPT: Its for 10 animations but lmao

-- Below; set the speed for every animation. leave as "DefaultSpeed" for the '16'. You can change it to like anything. local AnimSpeed1 = 1 local AnimSpeed2 = 16 local AnimSpeed3 = 16 local AnimSpeed4 = 16 local AnimSpeed5 = 16 local AnimSpeed6 = 16 local AnimSpeed7 = 16 local AnimSpeed8 = 16 local AnimSpeed9 = 16 local AnimSpeed10 = 16 -------------------------------------------- Don't edit below. local UrlCode = "http://www.roblox.com/Asset?ID=" local Animation = Instance.new("Animation") local Track = nil local CanPlay = true

function setBackpackDisplay(show) game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, show) end function setHealthDisplay(show) game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, show) end function setPlayerListDisplay(show) game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, show) end function setChatDisplay(show) game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, show) end function setAllDisplay(show) game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, show) end

blockEquip = script.resources.blockEquipment function loadAnimation(Id, PlayerSpeed, blockTools) if CanPlay == true then CanPlay = false Animation.AnimationId = (UrlCode..Id) Track = Humanoid:LoadAnimation(Animation) Track:Play() Humanoid.WalkSpeed = PlayerSpeed allowTools = blockTools print 'playing' if allowTools == true then setBackpackDisplay(false) blockEquip.Disabled = false end end end function UnloadAnimation() if CanPlay == false then blockEquip.Disabled = true setBackpackDisplay(true) Track:Stop() Humanoid.WalkSpeed = 16 print 'removing' CanPlay = true end end -------------------------------------------- 1 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot1) and CanPlay == true then loadAnimation(AnimSlot1, AnimSpeed1, AnimBlock1) elseif (string.upper(Key) == KeyPressSlot1) and CanPlay == false then UnloadAnimation() end end) -------------------------------------------- 2 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot2) and CanPlay == true then loadAnimation(AnimSlot2, AnimSpeed2, AnimBlock2) elseif (string.upper(Key) == KeyPressSlot2) and CanPlay == false then UnloadAnimation() end end) -------------------------------------------- 3 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot3) and CanPlay == true then loadAnimation(AnimSlot3, AnimSpeed3, AnimBlock3) elseif (string.upper(Key) == KeyPressSlot3) and CanPlay == false then UnloadAnimation() end end) -------------------------------------------- 4 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot4) and CanPlay == true then loadAnimation(AnimSlot4, AnimSpeed4, AnimBlock4) elseif (string.upper(Key) == KeyPressSlot4) and CanPlay == false then UnloadAnimation() end end) -------------------------------------------- 5 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot5) and CanPlay == true then loadAnimation(AnimSlot5, AnimSpeed5, AnimBlock5) elseif (string.upper(Key) == KeyPressSlot5) and CanPlay == false then UnloadAnimation() end end) -------------------------------------------- 6 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot6) and CanPlay == true then loadAnimation(AnimSlot6, AnimSpeed6, AnimBlock6) elseif (string.upper(Key) == KeyPressSlot6) and CanPlay == false then UnloadAnimation() end end) -------------------------------------------- 7 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot7) and CanPlay == true then loadAnimation(AnimSlot7, AnimSpeed7, AnimBlock7) elseif (string.upper(Key) == KeyPressSlot7) and CanPlay == false then UnloadAnimation() end end) -------------------------------------------- 8 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot8) and CanPlay == true then loadAnimation(AnimSlot8, AnimSpeed8, AnimBlock8) elseif (string.upper(Key) == KeyPressSlot8) and CanPlay == false then UnloadAnimation() end end) -------------------------------------------- 9 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot9) and CanPlay == true then loadAnimation(AnimSlot9, AnimSpeed9, AnimBlock9) elseif (string.upper(Key) == KeyPressSlot9) and CanPlay == false then UnloadAnimation() end end) -------------------------------------------- 10 Mouse.KeyDown:connect(function(Key) if (string.upper(Key) == KeyPressSlot10) and CanPlay == true then loadAnimation(AnimSlot10, AnimSpeed10, AnimBlock10) elseif (string.upper(Key) == KeyPressSlot10) and CanPlay == false then UnloadAnimation() end end)

Can someone tell me how to fix this? or help me make a new script, also how do i add space and shift in this row nstead of C, do i just need to type shift?

0
Please put this in a code block.... Ind1v1duals 43 — 6y
0
wdym Theroofypidgeot 21 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Put this in a normal script in Starter Gui

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humand = Character:WaitForChild("Humanoid")
local tool = script.Parent
local Mouse = Player:GetMouse()
local anim = Instance.new("Animation", Humand)
anim.AnimationId = "http://www.roblox.com/asset/?id=01468567293" --enter your animation id here


mouse.KeyDown:Connect(function(key)
    key = key:lower()
    if key == 'f' then -- put your key in the place of f
        local animTrack = Humand:LoadAnimation(anim)
        animTrack:Play()
    end
end)

This will play that animation when player press the key

Sorry i hadn't read what did you wrote but by the title i think this can be a answer

Ad

Answer this question