Okay, so I was told to try to make a script because one of my questions was asking how to do something instead of trying to make it myself then, asking and someone gave me a script so I looked through it and tried to add the same things to my own script. After this I look back then try to fixate any mistakes after I find out the user made a mistake so I fixed that. After I figured i'd try it on another script, it worked but it doesn't seem to work for this script. I figured out I had to make a variable that is 0 at default and adds one every time the key is clicked, after you tell the script that certain part of the script would make the variable = 1 then you tell it a certain part would make the variable = 2 and however many times u need it to count so I made this ```lua plr = game:GetService("Players").LocalPlayer char = plr.Character hum = char:WaitForChild("Humanoid") rad = math.rad s = char:WaitForChild('WhiteBlack') sw = s.Sword wc = s.Sword.Sword local w = Instance.new('Weld', sw) lh = char:WaitForChild('LeftHand') cero = script.Parent.Cero oof = script.Parent.HandToHand oof2 = script.Parent.SwordsManShip local Anim4 = Instance.new("Animation") Anim4.AnimationId = "http://www.roblox.com/Asset?ID=02919926374" local Anim4 = hum:LoadAnimation(Anim4) local dbounce = false local keys = 0
function onKeyDown(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.Q and dbounce == false then dbounce = true keys = keys + 1 keys = 1 print("Q was pressed") Anim4:Play() wait(0.5) wc.Enabled = false sw.Parent = char w.Part0 = lh w.Part1 = sw w.C0 = CFrame.new(0,-0.2,-2) * CFrame.Angles(rad(0),rad(180),rad(90)) oof.Disabled = true oof2.Disabled = false cero.Disabled = true
function onKeyDown(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.Q then keys = keys + 1 print("Q Pressed 2") end end wait()
while keys == 2 do Anim4:Play() oof.Disabled = false oof2.Disabled = true cero.Disabled = false w.Active = false wc.Enabled = true end end end game:GetService("UserInputService").InputBegan:connect(onKeyDown)
``` This basically welds a group to player then a part in that group is taken out this being a sword then placed near the LeftHand after it welds it to LeftHand and plays an animation before it changes.
That was the first click at least the second click does the opposite making the weld inactive and places it back where it was before.
Note that I get no errors from this script But, I do get the first print function ("Q Was Pressed") in output meaning the first part works; why isn't the second part working.?