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

Help with Animation Playing off of KeyCode in LocalScript?

Asked by 5 years ago
Edited 5 years ago

I'm trying to make a script that when the player clicks "T" it not only starts an animation but it enables the particles that are already placed in the character and have been disabled. Scripts not working any help ?


``local UserInputService = game:GetService("UserInputService") local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") local Animation = Instance.new("Animation") Animation.AnimationdID = "rbxassetid:2866299208" local track = Humanoid:LoadAnimation(Animation)

local particle = Character:WaitForChild("LeftUpperArm"):WaitForChild("ParticleEmitter") local particle1 = Character:WaitForChild("RightLowerArm"):WaitForChild("ParticleEmitter") local particle2 = Character:WaitForChild("RightUpperLeg"):WaitForChild("ParticleEmitter") local particle3 = Character:WaitForChild("UpperTorso"):WaitForChild("ParticleEmitter")

UserInputService.InputBegan:Connect(function(input, proc) if not proc and input.KeyCode == Enum.KeyCode.T then particle.Enabled = true particle1.Enabled = true particle2.Enabled = true particle3.Enabled = true track:Play() wait(3) track:Stop() end end)``

0
Sorry that it looks weird I don't know how to do the thing with the view source songboy50 77 — 5y
0
click the lua logo icon when youre writing and some ~ will appear write isnide them starmaq 1290 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Since you're not waiting for the Character it might be broken because of that. Or it is because you misspelled AnimationId at Animation.AnimationdID = "rbxassetid:2866299208". It could be because you misspelled the link "rbxassetid:2866299208", it should be "rbxassetid://2866299208".

Here's the fixed script:

local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer 
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid") 
local Animation = Instance.new("Animation") 
Animation.AnimationId = "rbxassetid://2866299208" 
local track = Humanoid:LoadAnimation(Animation)

local particle = Character:WaitForChild("LeftUpperArm"):WaitForChild("ParticleEmitter") 
local particle1 = Character:WaitForChild("RightLowerArm"):WaitForChild("ParticleEmitter") 
local particle2 = Character:WaitForChild("RightUpperLeg"):WaitForChild("ParticleEmitter") 
local particle3 = Character:WaitForChild("UpperTorso"):WaitForChild("ParticleEmitter")



UserInputService.InputBegan:Connect(function(input, proc) 
    if not proc and input.KeyCode == Enum.KeyCode.T then 
        particle.Enabled = true 
        particle1.Enabled = true
        particle2.Enabled = true 
        particle3.Enabled = true 
        track:Play() 
        wait(3) 
        track:Stop()
    end 
end)

I don't know your intentions, but you also might want to disable the particles at the end of the animation.

Ad

Answer this question