#Idk how to explain this
1 messages · Page 1 of 1 (latest)
Mouse.KeyDown:Connect(function(key)
if (key == 'q') then
change and play idle animation 1
elseif (key == 'e') then
change and play idle animation 2
end
this is how it should look like i just dont know how to change and play the animations
i actually tried to add animation and just play it but it doesnt work with multiple anims
Mouse.KeyDown:Connect(function(key)
local IdleAnimation = Instance.new("Animation")
IdleAnimation.AnimationId = "rbxassetid://180435571" -- this is the default idle anim
local AnimationPlay = animator:LoadAnimation(IdleAnimation)
if (key == 'q') then
IdleAnimation.AnimationId = "rbxassetid://86786797515857" -- my anim 1
local AnimationPlay = animator:LoadAnimation(IdleAnimation)
IdleAnimation:Play()
elseif (key == 'e') then
IdleAnimation.AnimationId = "rbxassetid://93109033026292" -- my anim 2
local AnimationPlay = animator:LoadAnimation(IdleAnimation)
IdleAnimation:Play()
end
end)
this is actaully what am i trying rn but i dont know it thats the wight way
READ EVERYTHING ABOVE!!!
pls help someone
does the first anim work
but then the second not
and the first one was still playing
even tho u pressed other key
@jagged heart
If youre talking about this script no anim works it says Play isnt a member of a
Animation @abstract flare
None of them work
yes
because
you gotta play the LoadAnim
not the animation itself
u do "Instance.new("Animation"):Play()"
@jagged heart
local AnimationPlay = animator:LoadAnimation(IdleAnimation)
AnimationPlay:Play()
like this
or animator:LoadAnimation(IdleAnimation):Play()
the same
but I think u still will have an issue
just test this then tell me if it still doesnt work
Ill try tmmrw cuz izs late but thanks ill let you know
i think it works
the problem is the animation loads and plays but its stuck in weird position between the previous animation and the current one.
ok i found another problem i have these 2 animations, if they have same animation priority, switching between them makes you stuck between the animation 1 and the animation 2 and the animations dont fully play. If i set different animation priority to each one of them, then one will just completely override the other and and second animation wont play at all @abstract flare hopefully i explained it enough.
i just need so if i play one animation it will fully play and if i play the other it will also fully play.
like actually switch between them.
??
u have to stop the first animation
when starting the second animation
@jagged heart
so u make ```local Animation1 = Animator:LoadAnimation(Animation1)
local Animation2 = Animator:LoadAnimation(Animation2)
if Key.KeyCode == Enum.KeyCode.L then
Animation2:Stop()
Animation1:Play()
else
Animation1:Stop()
Animation2:Play()
end```
oh makes sence
uhh where do i put the animationid?
wait
Mouse.KeyDown:Connect(function(key)
local IdleAnimation1 = Instance.new("Animation")
IdleAnimation1.AnimationId = "rbxassetid://88804290373500"
local Animation1Play = animator:LoadAnimation(IdleAnimation1)
local IdleAnimation2 = Instance.new("Animation")
IdleAnimation2.AnimationId = "rbxassetid://93109033026292"
local Animation2Play = animator:LoadAnimation(IdleAnimation2)
if (key == 'q') then
Animation1Play:Play()
Animation2Play:Stop()
elseif (key == 'e') then
Animation2Play:Play()
Animation1Play:Stop()
end
end)
I did this but it still doesnt work
@abstract flare
?
it iterally doesnt work i used it and it completely doesnt work
also the animations are still bugged, i used this script and it doest th exact same thing.
?
oh
The errors about animation are not related to the script!!! and i was trying to press the keys (it worked with (key == ) @abstract flare
** You are now Level 7! **
oh
u use key as in the mouse click
u should use userinputservice
@jagged heart
the Mouse.ButtonDown:Connect(function() <-- here doesnt have a argument as key
u use userinput service for input keys
like Q
E
R
or u use contextactionservice
but thats a little advanced
no its ok jus try userinput and if it still doesnt work tell me
yes
and the if?
UserInputService.InputBegan:Connect(function(Input, gameProcessedEvent) <-- Input is the key and gameProc is when ure like chatting
what u will always do u is
ok
UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
if GameProcessedEvent then return end
if Input.KeyCode == Enum.KeyCode.Q then
...
end
end)
ok ive done that and it works so thanks but my main problem still stays: the animation doesnt fully change when i change it
@abstract flare
uhh
well if i set both to core it does this
but if i set it to idle i think it wont load the other one at all
lemme try smth
ok i set both to idle but it still doesnt work
@abstract flare
ure creating a new animation everytime u click a key
put the animations outside userinput
wym
UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
if GameProcessedEvent then return end
local IdleAnimation1 = Instance.new("Animation")
IdleAnimation1.AnimationId = "rbxassetid://98227665013276"
local Animation1Play = animator:LoadAnimation(IdleAnimation1)
local IdleAnimation2 = Instance.new("Animation")
IdleAnimation2.AnimationId = "rbxassetid://132028349673064"
local Animation2Play = animator:LoadAnimation(IdleAnimation2)
if Input.KeyCode == Enum.KeyCode.Q then
Animation1Play:Play()
Animation2Play:Stop()
elseif Input.KeyCode == Enum.KeyCode.E then
Animation2Play:Play()
Animation1Play:Stop()
end
end)
this is what i use rn
u just put them outside userinput
what specifically?
like ```
Local anima
userinput```
because whenever u click a key u create a new animation
thats why its overwriting the other animation
IdleAnimation1.AnimationId = "rbxassetid://98227665013276"
local Animation1Play = animator:LoadAnimation(IdleAnimation1)
local IdleAnimation2 = Instance.new("Animation")
IdleAnimation2.AnimationId = "rbxassetid://132028349673064"
local Animation2Play = animator:LoadAnimation(IdleAnimation2)
UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
if GameProcessedEvent then return end
if Input.KeyCode == Enum.KeyCode.Q then
Animation1Play:Play()
Animation2Play:Stop()
elseif Input.KeyCode == Enum.KeyCode.E then
Animation2Play:Play()
Animation1Play:Stop()
end
end)```
like this
IT WORKES
yoo tysm ik i was annoying
but im tryna understand ts and i think i just got it
@abstract flare thanks again
k
have fun
idk how to rly explain but ill try my best.
So what you just saw is a system does something when key is pressed and.. i want to make it so that when i used q i can use another key to do something else but if i use different key like e then it will not work. Example: Q then N: something happens, E then N nothing happens/something different happens. Do you think there is a way to do such a thing? It might be much more difficult but i would appriciate if you could help me with this, its the last thing i need.
its ok if you dont tho