#my clientevent isnt listening to fireallclients
1 messages · Page 1 of 1 (latest)
lemme send the code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local triggerEvent = ReplicatedStorage:WaitForChild("TriggerCommentary")
local lines = {
"Yo! Where did that scream come from?",
"I think we should follow direction of the sound. Someone might be in danger.",
"But urm, is it really safe?. Could be a trap",
"We can try searching I guess...Who knows, someone life could be in danger"
}
triggerEvent:FireAllClients(lines)
this is serverscriptservice code
im trying to send this table to all clients
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local commentaryGui = playerGui:WaitForChild("CommentaryNo1")
local frame = commentaryGui:WaitForChild("Frame")
local nameLabel = frame:WaitForChild("PlayerNameLabel")
local dialogueLabel = frame:WaitForChild("DialogueLabel")
local triggerEvent = ReplicatedStorage:WaitForChild("TriggerCommentary")
print("LocalScript is running!")
local players = game:GetService("Players"):GetPlayers()
local playerNames = {}
for _, player in ipairs(players) do
table.insert(playerNames, player.Name)
end
local function typeText (text, label)
label.Text = ""
for i = 1, #text do
label.Text = string.sub(text, 1, i)
wait(0.05)
end
end
triggerEvent.OnClientEvent:Connect(function(lines)
print("RemoteEvent received on client!")
local randomPlayerIndex = math.random(1, #playerNames)
nameLabel.Text = playerNames[randomPlayerIndex]
print("code works!")
end)
this is client sided script
it is incomplete so dont point that out, im simply testing if the client listens to the script fired by the server
well the prints below onclientevent dont work when I press play. This means onclientevent isnt listening to the server
your server code ran earlier before your client code can detect that
place a task.wait before fireallclients
never in my lifetime could I have ever noticed that 💀
but thanks