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

Help me, the animations when you press a key does not work. Any suggestions?

Asked by 4 years ago
local TM = require(script.Parent.Parent:WaitForChild("ToolManagment"))
Kick = false
Equipped = false

local power
local maxF

Tool = script.Parent
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()

script.Parent.Equipped:connect(function(m)
    Equipped = true
end)

script.Parent.Unequipped:connect(function(m)
    Equipped = false
end)


Mouse.Button1Down:connect(function()
    if Equipped == false then return end
    if TM.GetUsing() then return end
    TM.SetUsing(true)
    TM.showPowerBar()
    TM.setWindUp(true)
local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()


local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=4554918372"

mouse.KeyDown:connect(function(key)
  if key == "z" then
   local playAnim = humanoid:LoadAnimation(anim)
   playAnim:Play()

    end
end)
    power = 60
    Angle = 100
    maxF = Vector3.new(10e+006, Angle, 10e+006)
    for i=1,25 do
        if TM.getWindUp() then
            power = power + 1.6
            Angle = Angle + 275
            TM.powerUp(i/25)
            wait()
        else 
            break
        end
    end
end)

Mouse.Button1Up:connect(function()
    if TM.getWindUp() and TM.GetUsing() and Equipped then
        TM.setWindUp(false)
        Kick = true
        wait(0.7)
        Kick = false
        TM.ResetWelds()
        TM.resetPowerBar()
        wait(0.2)
        TM.SetUsing(false)
        TM.setWindUp(false)
    end
end)








Player.Character["Right Leg"].Touched:connect(function(hit)
    if hit.Name ~= "TPS" then return end
    if Kick == false then return end
    if hit.Owner.Value ~= Player then
        ChangeOwner(hit)
    end
    Kick = false
    F = Instance.new("BodyVelocity")
    F.Velocity = Player.Character["Right Leg"].CFrame.lookVector * power
    F.MaxForce = Vector3.new(10e+006,Angle,10e+006)
    F.Parent = hit
    game.Debris:AddItem(F, 0.3)
end)

function ChangeOwner(ball)
    game.ReplicatedStorage.ChangeOwner:FireServer(ball)
end
0
Maybe add "wait(1)" at the very beginning User#29913 36 — 4y
0
Try parenting the animation in line 33 to something. I think that's why it didn't work. Also, try using Tool.Activated, not mouse.MouseButton1Down. It's a very effective technique I use a lot. Sensei_Developer 298 — 4y

Answer this question