Remote Event Not Executing

You can write your topic however you want, but you need to answer these questions:
I’m trying to use a remote event to make the character play an animation when you click a button. The LocalScript calls the remote event but nothing happens on the ServerScript, it doesn’t even run I made it print “Hello” if it runs but it doesn’t.
Screenshot 2024-06-04 at 7.48.41 PM
Screenshot 2024-06-04 at 7.49.12 PM

Input script is the LocalScript, AttackEvent is the event, and AttackScript is the serverScript

Local Script

mouse.Button1Down:Connect(function()
	game.ReplicatedStorage.Attacks.Punctuator.M1.AttackEvent:FireServer(mouse)
end)

ServerScript:

script.Parent.AttackEventEvent.OnServerEvent:Connect(function(plr, mouse)
	local LoadedAnim = plr.Character.Humanoid:LoadAnimation(script.Parent.Animation)
	LoadedAnim:Play()
	print("hello")
end)

It might because you spelled “AttackEvent” wrong when referencing them in your Server Script. On the Server Script, you reference it as AttackEventEvent, when in your image, it is spelled as AttackEvent. Also, sorry for being picky about small stuff, but here are just a few helpful nitpicks to fix:

  1. I recommend using Humanoid.Animator:LoadAnimation() to load your animations, as just loading the animations on the humanoid is deprecated.
  2. You can’t send the mouse object through the client to the server, as the mouse only exists on the client, meaning it would be nil. Exceptions to the mouse is that you can send mouse properties and anything relating to the mouse, but not just the mouse object itself.

I fixed the error but ut still doesnt work

i meant to type it not ut my bad

i fixed all of the mentioned problems but it still doesn’t work

Make sure you’ve checked the output for any errors and also make sure that you’ve added a valid rbxassetid in your animation’s AnimationId property

Try printing hello right after the mouse.Button1Down function in your LocalScript, and tell me if it prints or not when you left click.

it prints in the local script but not in the serverscript

there is nothing in the output log and it is is valid

1 Like

If there’s any more in your server script, make sure everything else isn’t yielding (ex you have a whole loop not in another thread)

nothing else is in the script, that is the entire script

1 Like

I think I realized the issue. While testing the script, your Server Script didn’t seem to function at all. The thing is, Server Scripts don’t work in ReplicatedStorage. The quick solution is to move the script into ServerScriptService, and instead of script.Parent.AttackEvent.OnServerEvent, use game.ReplicatedStorage.Attacks.Punctuator.M1.AttackEvent.OnServerEvent.

1 Like

That doesn’t work, the client cant access the server.

ill just put the event in replicated storage instead

Yeah, sorry for the confusion. All I meant is that Server Scripts don’t function in ReplicatedStorage, so you should move the Server Script to ServerScriptService instead. Sorry if I made it way too confusing for you.

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