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

No error codes but its still not working, and the animation doesnt play?

Asked by
FBS_8 25
4 years ago

localscript:

01local anim = Instance.new("Animation")
02anim.AnimationId = "rbxassetid://4975456908"
03anim.Name = "TauntAnim"
04 
05local tool = script.Parent
06local mouse = game.Players.LocalPlayer:GetMouse()
07 
08mouse.KeyDown:Connect(function(key)
09    if key == "E" and tool.Equipped then
10        anim:Play()
11    end
12end)
13 
14mouse.KeyUp:Connect(function(key)
15    if key == "E" and tool.Equipped then
16        anim:Stop()
17    end
18end)

1 answer

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

You have to load the animation first. Also, I'd use UserInputService.

01local UserInputService = game:GetService("UserInputService")
02 
03local anim = Instance.new("Animation")
04anim.AnimationId = "rbxassetid://4975456908"
05anim.Name = "TauntAnim"
06anim.Parent = script
07 
08local tool = script.Parent
09local player = game.Players.LocalPlayer
10 
11local clicked = false
12 
13local loadedAnim
14 
15UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
View all 28 lines...

The InputBegan event fires when an input begins (keyboard, mouse, etc.) Then there's an if statement checking if the player is not in chat, and if the input is "E" on their keyboard. Then the loadedAnimation plays. The InputEnded is the same thing but it stops the animation.

Ad

Answer this question