RemoteEvent not working

  1. What do you want to achieve?
    I have a script in ServerScriptService and a local script inside an NPC character which itself is in Workspace. I’m trying to fire a RemoteEvent in the script that makes the local script make the NPC character display a chat bubble

  2. What is the issue?

This function in the script works as “check1” is printed (I’m calling the function in another part of the script):

local Replicated = game:GetService("ReplicatedStorage")
local comm = Replicated.NPCcomm

local function manageRegister(bot)
	local user = bot:GetAttribute("assigned")
	local plr = game.Players[user]
	
	comm:FireAllClients(user, "Send", "Wave")
	print("check1")
end

But this is everything in localScript, and it does not work. I know this because “check2” is not being printed.

local TextChatService = game:GetService("TextChatService")
local Replicated = game:GetService("ReplicatedStorage")
local comm = Replicated.NPCcomm

comm.OnClientEvent:Connect(function(one, two, three)
	print("check2")
	TextChatService:DisplayBubble(script.Parent.Head, three)
end)

There are no errors at all so I’m not sure how to fix this, any help is appreciated!

There is nothing wrong with the scripts but maybe try to add :WaitForChild for the comm remote event

local comm = Replicated:WaitForChild("NPCcomm")

and make sure that the player exists before continuing:

if plr then 
   comm:FireAllClients(user, "Send", "Wave") 
   print("check1") 
end

Thank you so much - I added the :WaitForChild but it still doesn’t work… There’s nothing wrong with the player existing as “check1” is still being printed. There are no errors as well.

1 Like

Okay so do you have any other scripts on the client side using same remote?

Check to make sure your ‘user’ value is correct. Try printing that.

I think that might have been the problem - what I was doing was keeping a local script inside the template NPC and making multiple scripts for each NPC. When I tried moving the LocalScript to StarterPlayerScripts and kept it as one script for all NPCs it just started to work. Thank you all so much!

Just wondering; why doesn’t the localScript work if I have multiple scripts using the same remote (as that was the issue)?

If multiple scripts are connected to the same RemoteEvent, they might overwrite each other’s connections, leading to other scripts not receiving the event.

1 Like

Thank you so much, that makes sense. I thought that all the scripts would run.

1 Like

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