When I send a RemoteEvent I can't seem to get it to play a animation

Ok so My previous post got flagged cuz I didn’t say enough so lemme say enough

there I said ‘enough’

but yeah so the script gets its remote event signal sent out then boom shabam nothing happens, sometimes depending on where the script is I get a few errors usually telling me that wait for child cant be indexed or nothing so Idk if its position but it doesn’t work no matter, so can I get a script fix for this? it shouldn’t be too hard and I honestly have spent 3 days trying to fix this, I just want a solid answer whats going on?

the script:

local player = game:GetService("Players").LocalPlayer.Character
local GumPunch = Instance.new("Animation")
local GumGumPistol = game:GetService("ReplicatedStorage"):WaitForChild("RubberFruit_Events").GumPistol
local humanoid = player:WaitForChild("Humanoid")
GumPunch.AnimationId = "http://www.roblox.com/Asset?ID=13475511279"

GumGumPistol.OnClientEvent:Connect(function(player, PistolTrigger)
	GumPunch:Play() --Plays anim
end)

You need to set the parent of the GumPunch, which would be “player”.
GumPunch.Parent = player

1 Like

There are many issues with your script, try this:

local GumGumPistol = game:GetService("ReplicatedStorage"):WaitForChild("RubberFruit_Events"):WaitForChild("GumPistol")

local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait() -- You should wait for the Character to spawn, is not inmediately
local humanoid = char:WaitForChild("Humanoid") -- humanoid is in char not player

local GumPunch = Instance.new("Animation")
GumPunch.AnimationId = "rbxassetid://13475511279" -- you had an url issue in here
GumPunch.Parent = char -- parent the animation somewhere, the character, the pistol, simply somewhere
local animTrack = humanoid:WaitForChild("Animator"):LoadAnimation(GumPunch) -- Animations should be loaded into Animator to get an AnimationTrack to Play()

GumGumPistol.OnClientEvent:Connect(function(player, PistolTrigger)
	animTrack:Play() -- now you can play it
end)

Additionally. You dont need to create the animation instance from inside the local script, you could have the animation instance with its proper ID within the tool, weapon, script, model, you are giving to player, you dont need to create the animation instance from script

1 Like

If your having the client play an animation through a remote event, and that’s all it does, just play the animation on the server. But I recommend rewriting the code to play the animation on the client with no remote event.

1 Like

I used this method but when put in it doesn’t print something in it out, like its not running, its in a local script inside of practically everything I can find, and when I change the client event to server like it should be I get an error, server events dont work on local scripts

please respond it didn’t work ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

Honestly I dont see what effort you made in order to fix it, you are not showing your code or explaining your issue.

The code I provided is not a “method” its just the very basics on what you should do to play an animation.

Look, without even using your RemoteEvent, this is a local script, and the animation runs normally:

local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait() -- You should wait for the Character to spawn, is not inmediately
local humanoid = char:WaitForChild("Humanoid") -- humanoid is in char not player

local GumPunch = Instance.new("Animation")
GumPunch.AnimationId = "http://www.roblox.com/asset/?id=10714347256" -- An ID of a Default Roblox animation
GumPunch.Parent = char -- parent the animation somewhere, the character, the pistol, simply somewhere
local animTrack = humanoid:WaitForChild("Animator"):LoadAnimation(GumPunch) -- Animations should be loaded into Animator to get an AnimationTrack to Play()

animTrack:Play()

I DID IT MYSELF BABY WOOOOOO DIDNT USE THAT SCRIPT THAT DIDN’T WORK, THE SOLUTION WAS TO INSTEAD OF MAKING A NEW SCRIPT SPECIFICALLY FOR ANIMATING ON A LOCAL I SIMPLY INSIDE OF THE SAME SERVER SCRIPT THAT RECIEVES THE THINGY PUT A NVM LEMME SHOW U

local GumGumPistol = game:GetService("ReplicatedStorage"):WaitForChild("RubberFruit_Events").GumPistol
local RS = game:GetService("ReplicatedStorage")
local GumGumPistol = game:GetService("ReplicatedStorage"):WaitForChild("RubberFruit_Events").GumPistol
local RS = game:GetService("ReplicatedStorage")
local GumPunch = Instance.new("Animation")
local GumGumPistol = game:GetService("ReplicatedStorage"):WaitForChild("RubberFruit_Events").GumPistol
GumPunch.AnimationId = "http://www.roblox.com/Asset?ID=13475511279"


GumGumPistol.OnServerEvent:Connect(function(player, PistolTrigger)
	print("RecievedEvent")
--animation usually was tried to play here or in another script right here
	print("BeginningStretch")
	wait(0.1)
	
end)
 --past this is what fixed it
GumGumPistol.OnServerEvent:Connect(function(player)--player is the player who sent the remote event --so I basically defined the player in a server script using the remote itself
	GumPunch.Parent = player.Character
	local animTrack = player.Character.Humanoid:WaitForChild("Animator"):LoadAnimation(GumPunch) -- Animations should be loaded into Animator to get an AnimationTrack to Play()
	animTrack:Play()
	print("WOOO")
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.