Hello so i am trying to send array to the multiple localscripts but one of the localscripts dont recieve it. can anyone tell me why? and if multiple localscripts cant recieve it. what can i do it?
code where it doesnt recieve
local plr = game.Players.LocalPlayer;
local mouse = plr:GetMouse();
local gui = plr.PlayerGui;
local landTerraformationButton =gui.ScreenGui:WaitForChild("TerraformButton");
local upButton = gui.ScreenGui:WaitForChild("UpTerraform");
local downButton =gui.ScreenGui:WaitForChild("DownTerraform");
local ts = game:GetService("TweenService")
local rs = game:GetService("RunService")
local camera = workspace.CurrentCamera
local truth = true
local part = game.ReplicatedStorage:WaitForChild("LOL");
local scMesh = game.ReplicatedStorage:WaitForChild("SCMesh");
local arr = nil;
local n = nil;
scMesh.OnClientEvent:Connect(function(player, matrix, size)
print("stage 1-Beta, sending...");
arr = matrix;
n = size;
end)
code where it recieves
local scMesh = game.ReplicatedStorage:WaitForChild("SCMesh");
local csMesh = game.ReplicatedStorage:WaitForChild("CSMesh");
scMesh.OnClientEvent:Connect(function(player, arr, n)
print("stage 1, sending...");
csMesh:FireServer(player, arr, n);
end)
I can’t figure out why one client isn’t getting an event if I can’t see how the server is sending them; you can’t send information from one client to another, it has to go through the server first
Yes multiple scripts can connect to the same remote event. perhaps the code above the first connection is yielding too much and it connects after the server has sent the remote.
Then I can only conclude that it’s likely what @bytesleuth mentioned; the remote is probably being fired before the LocalScript can connect to it. So I would recommend doing something like this at the beginning of the script and see what happens:
local scMesh = game.ReplicatedStorage:WaitForChild("SCMesh");
scMesh.OnClientEvent:Connect(function(matrix, size)
print('detected')
end)
Explanation
You don’t need to pass player to the client’s OnClientEvent signal; the client already has access to the player. The server needs the player so that it knows which client to fire the remote to.
Your signal parameters already look like:
RemoteEvent.OnClientEvent:Connect(arr, n)
By adding player, it looks like:
RemoteEvent.OnClientEvent:Connect(player, arr, n)
--> The parameter's actual values: (any, any, nil)