Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My remoteevent isn't going through??

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!

2 comments

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

0

No, You can fire it from a server script 1st

2 answers

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

1 comment

0

did that, it didn't change anything

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

This discussion is preserved as it was. New answers, comments, and votes are closed.