Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My remoteevent isn't going through??

Asked by 3 years ago

Server script

local sendTables = game.ReplicatedStorage.RemoteEvents.SendTables 
local module = require(game.ServerScriptService.module)

local players = {}
local non_players = {}

while true do
    for i, plr in pairs(game.Players:GetPlayers()) do
        if plr.TeamName.Value == 'Player' and plr.ListedOnHealth.Value == false then
            if module.checkForTable(non_players, plr.Name)  then
                table.remove(non_players, table.find(non_players, plr.Name))
            end
            table.insert(players, 1, plr.Name)
            plr.ListedOnHealth.Value = true
        elseif plr.TeamName.Value ~= 'Player' and plr.ListedOnHealth.Value == true then
            if module.checkForTable(players, plr.Name) then
                table.remove(players, table.find(players, plr.Name))
            end
            table.insert(non_players, 1, plr.Name)
        end
    end 
    print(players)
    print(non_players)
    sendTables:FireAllClients(players, non_players)
    wait(0.1)
end

Local Script

local frame = script.Parent.Frame
local template = frame.Template
local sendTables = game.ReplicatedStorage.RemoteEvents.SendTables




sendTables.OnClientEvent:Connect(function(plr, players, non_players)
    if players and non_players then
        for i, plr in pairs(players) do
            print('going thru')
            if script.Parent:FindFirstChild(plr.Name) == nil then
                local newTemp = template:Clone()
                newTemp.Name = plr.Name
                newTemp.Parent = frame
            end
        end
        for i, plr in pairs(non_players) do
            print('going thru2')
            if script.Parent:FindFirstChild(plr.Name) ~= nil then
                local destroyPlayer = script.Parent:FindFirstChild(plr.Name)
                destroyPlayer:Destroy()
            end
        end
    end
end)

I don't know what the problem is. If you do give an answer, please describe why. Thank you!

0
I don't know if this is true or not but i'm pretty sure you have to fire the remote event from a local script and wright OnServerEvent in a script sameb556 -12 — 3y
0
No, You can fire it from a server script 1st Galaxybombboy 134 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

The first thing I notice in the local script you have

sendTables.OnClientEvent:Connect(function(plr, players, non_players)

Since its in the local script you do not need to pass plr. Since the local script only knowns the client as the player

Only in server scripts when firing event you need to say which player, but the listener (the client) doesn't need to know since the server sent it directly to that client

0
did that, it didn't change anything BCthegreat407 12 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Figured out that I just worded my variables wrong. Thank you guys for trying to help

Answer this question