Ad
Log in to vote
0

How to bind the space bar to an animation?

Asked by 14 days ago

I'm trying to make a jumping animation/sprite, I wanted to make it so whenever the player taps the spacebar the sprite plays.

How the script is supposed to work: When the spacebar is pressed the id's are supposed to cycle though while the player is jumping, making the sprite. Here is my failed attempt.

JumpingID = "http://www.roblox.com/asset/?id=6588763600" -- Ids
JumpingID1 = "http://www.roblox.com/asset/?id=6596998485"
JumpingID2 = "http://www.roblox.com/asset/?id=6597000062"
JumpingID3 = "http://www.roblox.com/asset/?id=6597008331"
JumpingID4 = "http://www.roblox.com/asset/?id=6597011900"
JumpingID5 = "http://www.roblox.com/asset/?id=6597012454"
JumpingID6 = "http://www.roblox.com/asset/?id=6597013053"
JumpingID7 = "http://www.roblox.com/asset/?id6597013593="

jumping = false
UserInputService = game:GetService("UserInputService")
local hum = script.Parent.Parent:FindFirstChild("Humanoid")
local pose2 = script.Parent:FindFirstChild("PoseBooltest1")
local df = script.Parent.Front2.Front2
local go = false
--------------------------
UserInputService.InputBegan:Connect(function(input,gameProccesedEvent)
    if input.KeyCode == Enum.KeyCode.Space then --flips through images
if df.Image == JumpingID then
    df.Image = JumpingID1
elseif df.Image == JumpingID1 then
    df.Image = JumpingID2
    jumping = true
elseif df.Image == JumpingID2 then
    df.Image = JumpingID3
    jumping = true
elseif  df.Image == JumpingID3 and jumping then
    df.Image = JumpingID4
elseif  df.Image == JumpingID4 then
    df.Image = JumpingID5
    jumping = false
elseif df.Image == JumpingID5 and jumping == false then
    df.Image = JumpingID6
elseif df.Image == JumpingID6 then
    df.Image = JumpingID7
elseif  df.Image == JumpingID7 then
    df.Image = JumpingID
    jumping = false
    wait(3)
    jumping = false
    df.Image = JumpingID
end
end
end)

3 answers

Log in to vote
0
Answered by 14 days ago

At line 08, U mispelt and made ?idblahblah= instead of ?id=blahblah

0
fixed, but same results SilverishReign 55 — 14d
Ad
Log in to vote
0
Answered by 14 days ago
local UserInputService=game:GetService("UserInputService")
local df=script.Parent.Front2.Front2

local tab,i,debounce={6588763600,6596998485,6597000062,6597008331,6597011900,
6597011900,6597011900,6597011900,6597012454,6597013053,6597013593},1,false
UserInputService.InputBegan:Connect(function(input)
    if debounce then return end
    if input.KeyCode == Enum.KeyCode.Space then
        debounce=true
        df.Image="rbxassetid://"..tab[i]
        wait(3)
        i=i<#tab and i+1 or 1
        debounce=false
    end
end)
Log in to vote
0
Answered by 14 days ago

Click play, open workspace then click ur username in worspace, it should have a script called animate. Copy animate and its children then stop the game. Paste the animate script and its children into startercharacterscripts inside starter player. You can change the jump animation by editing that script and putting the ID there.

For your informaition:

The animate script's children are values so that the script can copy the id from the values then use the animation.

Answer this question