****Sorry if the title sounds weird it's the 100 character limit**** This is apart of a script in a game I'm making, the original script takes a sword from a sheath that is attached to the player via welding and, it makes the sword weld to the player's hand whilst playing this animation but, that doesn't matter so I narrowed it down so u can focus on the only parts you need to focus on to answer this question for me.
This is the script, it's a simple script that plays an animation when a key is pressed but I can't figure out how to make it so if I clicked the key twice it would play a different animation in my case put the sword back in the sheath.
local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") local Anim4 = Instance.new("Animation") Anim4.AnimationId = "http://www.roblox.com/Asset?ID=02919926374" local Anim4 = Humanoid:LoadAnimation(Anim4) function onKeyDown(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.T then print("T was pressed") Anim4:Play() end end game:GetService("UserInputService").InputBegan:connect(onKeyDown)
local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") local Anim4 = Instance.new("Animation") Anim4.AnimationId = "http://www.roblox.com/Asset?ID=02919926374" local Anim4 = Humanoid:LoadAnimation(Anim4) local keys = 0 local dbounce = false function onKeyDown(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.T and dbounce == false then dbounce = true keys = keys + 1 function onKeyDown(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.T then keys = keys + 1 end end) wait(1) if keys = 2 then animation code here end print("T was pressed") Anim4:Play() end end game:GetService("UserInputService").InputBegan:connect(onKeyDown)
this should work or at least close hope this helps
Closed as Not Constructive by SerpentineKing and c0des
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?