I’m trying to play an animation when Q is pressed.
script (line 49 and 50 is where it prints/plays)
local lightbeam
lightbeam = true
local uis = game:GetService("UserInputService")
local equipted
local lightsaberStatus
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local h = char:WaitForChild("Humanoid")
script.Parent.Equipped:Connect(function(Mouse)
equipted = true
Mouse.Button1Down:Connect(function()
if lightbeam == true then
wait(0.3)
script.Parent.Light.Transparency = 0.07
lightbeam = false
script.lightsaber_powerup:Play()
lightsaberStatus = true
else
wait(0.3)
script.Parent.Light.Transparency = 1
lightbeam = true
script.Lightsaber_Close:Play()
lightsaberStatus = false
end
end)
end)
script.Parent.Unequipped:Connect(function()
equipted = false
end)
local SwingAnim = script.swing
local AnimationTrack = h:LoadAnimation(SwingAnim)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
if equipted == true then
if lightsaberStatus == true then
print("why")
AnimationTrack:Play()
local bean = math.random(1,4)
if bean == 1 then
script["Lightsaber Swing 1"]:Play()
end
if bean == 2 then
script["Lightsaber Swing 2"]:Play()
end
if bean == 3 then
script["Lightsaber Swing 3"]:Play()
end
if bean == 4 then
script["Lightsaber Swing 4"]:Play()
end
end
end
end
end)
I have no clue on what is going wrong/not working
