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

Animation script with hotkey is failing. Why is this happening?

Asked by 5 years ago
Edited 5 years ago

I have tried a script where I press a key and it makes an animation happen. For some reason, the script only works when I jump. This is a Server Script.

local repstorage = game:WaitForChild("ReplicatedStorage")
local Remote = repstorage:WaitForChild("IceStart")


Remote.OnServerEvent:connect(function(player)

    local char = player.Character
    script.Dmg.Player.Value = player.Name
    local folder = workspace:FindFirstChild("DebrisFolder") or Instance.new("Folder",workspace)
    folder.Name = "DebrisFolder"

local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://000"
local Move = char.Humanoid:LoadAnimation(Anim)
Move:Play()

local position = Instance.new("BodyVelocity",char.HumanoidRootPart)
position.MaxForce = Vector3.new(99999999999999,99999999999999,99999999999999)
position.P = 300
position.Velocity = char.HumanoidRootPart.CFrame.LookVector * 1
game.Debris:AddItem(position,2)

There is also another script that connects to make that work.

local repstorage = game:WaitForChild("ReplicatedStorage")
local Remote = repstorage:WaitForChild("IceStart")

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
cool = true

Mouse.KeyDown:connect(function(key)
    key = key:lower()
    if key == "z" then
    if cool ~= true then return end
    cool = false

    Remote:FireServer()








    wait(5)
    cool = true
    end
end)
0
keydown is decaperated User#23365 30 — 5y
0
Thanks. keyDown now or just keydown ChasingNachos 133 — 5y
0
no use UserInputService, InputBegan User#23365 30 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
 --  This should make the animation work. Should be a local script in starterGui.
-- Don't delete your scripts. Just disable them and make sure this plays the animation

Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
cool = true

mouse.KeyDown:connect(function(key)
    key = key:lower()
    if key == "z" then
        if cool == true then
            cool = false
            local Anim = Instance.new("Animation")
            Anim.AnimationId = "rbxassetid://000"
            local humanoid = plr.Character:WaitForChild("Humanoid")
            local playanim = humanoid:LoadAnimation(Anim)
            playanim:Play()
        end
    end
end)
0
keydown is decaperated User#23365 30 — 5y
Ad

Answer this question