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
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!
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.
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.