i have this npc in my lobby and the lobby is put into serverstorage and then placed back in workspace once the game is over and sometimes the npc’s chat doesnt show for other players until another game cycle even though its all in a server script
the code for the npc:
local character = script.Parent.Parent.Parent
local talkPart = character:WaitForChild("Head")
local functionLibrary = require(game.ServerScriptService.FunctionLibrary)
local prompt = script.Parent
local cooldown = false
prompt.Triggered:Connect(function(player)
if cooldown == false then
local random = math.random(1, 5)
if random == 1 then
functionLibrary.Chat(talkPart, "Custom", "Please don't die out there.")
elseif random == 2 then
functionLibrary.Chat(talkPart, "Custom", "Some strong foes have a chance to drop a weapon for you!")
elseif random == 3 then
functionLibrary.Chat(talkPart, "Custom", "Some enemies may be a hindrance to their fellow companions.")
elseif random == 4 then
functionLibrary.Chat(talkPart, "Custom", "Please don't go out there without a healer, you may regret it.")
elseif random == 5 then
functionLibrary.Chat(talkPart, "Custom", "The more damage you deal to an enemy the more money you'll gain after they die!")
elseif random == 6 then
functionLibrary.Chat(talkPart, "Custom", "I can give you useful tips!")
end
end
end)