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

ROBLOX Gun animation is not working, players hold guns with one hand?

Asked by 4 years ago
Edited 4 years ago

I have edited some old non FE compatible weapons to be FE compatible. The guns can now kill players. I did not need to use any additional scripts to make the guns work, all I did was add a DamageEvent to the gun and then changed the TakeDamage script inside the gun. The gun has one more problem, which is the animations. On my screen I hold and fire the weapon with two hands, but to everyone else the gun is held with one hand while idle but with two hands when shooting. I am trying to fix it so the gun is held with two hands at all times. The gun uses a RayCast assault weapon script and does have a "recoil" animation which breaks the gun if removed. I tried to edit the animation to be one of my own and it made no difference. Does anyone know what I can do to fix this?

0
Maybe use a remote event to fire the animation? User#32819 0 — 4y
0
How would I do that? I don't know much about the script itself and the only reason I was able to make the gun fire was from a tutorial I found. I'm a beginner to this DabDruxy -9 — 4y
0
Do you know anything about remote events? If you don't I'll teach you how to do it through discord. User#32819 0 — 4y

2 answers

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

Hello!

Note: I may have misread your question, so I hope this is what you were asking for.

So what you'll need to do is use RemoteEvents for the idle/hold animation because by default tools use one hand (another thing you should check is the AnimationPriority in the AnimationEditor), because it is only firing the animation on the client which means only the person who used the gun can see it.

So first off create a RemoteEvent and put it in ReplicatedStorage.

In the script in the tool, when the animation is supposed to fire, put this line of code:

game.ReplicatedStorage.RemoteEvent:FireServer(animation) --animation should be the animation 

And then create a server/normal script and put it in ServerScriptService. Put this in it:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, animation)
    local hum = player.Character:WaitForChild("Humanoid")
    hum:LoadAnimation(animation)
    print("animation fired") 
end)

If this doesn't work, please reply in the comments and tell me what's wrong.

I hope this helps.

-ProqrammedGreen

0
Hi, first off I want to add that your post brought me a lot closer to fixing my issue, and I thank you for that. I did the things that you said (hopefully the right way, I'm not the best at this) and the gun still seemed to have the same issues. The original script for the animation of the gun was: if RecoilAnim then / RecoilTrack = MyHumanoid:LoadAnimation(RecoilAnim) / end. DabDruxy -9 — 4y
0
I changed that to: if RecoilAnim then game.ReplicatedStorage.HoldEvent:FireServer(RecoilAnim) --animation should be the animation end. For the script in ServerScriptService I put game.ReplicatedStorage.HoldEvent.OnServerEvent:Connect(function(player, RecoilAnim) local hum = player.Character:WaitForChild("Humanoid") hum:LoadAnimation(RecoilAnim) print("animation fired") end) DabDruxy -9 — 4y
0
Sorry the comments aren't in Lua form, don't know the format for that. I will add that I did a CTRL - F search in the script and found some other codes relating to the animation, which were: local RecoilAnim and RecoilAnim = WaitForChild(Tool, 'Recoil'). Again, this all might be confusing due to how I am wording it. If you can't find a solution, I thank you for what you have done so far. DabDruxy -9 — 4y
0
I'm glad I could help! proqrammed 285 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I think this DevForum post will help you

https://devforum.roblox.com/t/how-to-animate-tool-parts-guns-knifes-etc/359484

Answer this question