Hey Developers,
I’m trying to make a NPC talk a random order that has been generated by the server, however I can’t get it to work and I can’t find any console errors. I’ll show my code below so you can take a look!
Server Code
local Orders = {"Cookie","White Chocolate Cookie","Blue Cookie","random food"}
local RandomOrderEvent = game.ReplicatedStorage.RandomFoodEvent
--Create random food order
local randomorder = Orders[math.random(1, #Orders)]
--Functions
local function loadnpcs()
RandomOrderEvent:FireAllClients(randomorder)
end
--MainCode
loadnpcs()
NPC Code
local RandomOrderEvent = game.ReplicatedStorage.RandomFoodEvent
RandomOrderEvent.OnClientEvent:Connect(function(randomorder)
game:GetService("Chat"):Chat(script.Parent.Head, randomorder, Enum.ChatColor.Green)
end)
I’m not really sure what I’m doing wrong as I’m quite new to this, any help would be appreciated.