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

Remote event not firing because of table issues?

Ok, before you close this thread Feahren, I tried to make this work but it didn't. The event on line 18 isn't firing, no errors are shown. Thanks!


game.ReplicatedStorage.WaitingTeam.OnServerEvent:Connect(function(plr)
local piwt = {}
local pig = {}
table.insert(piwt,plr)
if #piwt == 1 then
	for i, v in pairs(piwt) do
	     table.insert(pig,v)
	end
	for i, v in pairs(pig) do
		if v == plr.Name then
			
		local roles = {"Werewolf","Seer","Archer","Cupid","Banana Doctor","Villager","Bodyguard"}
		for i, v in pairs(roles) do
			local role = math.random(1,#roles)
		    table.remove(roles,table.find(roles,role))
		     
			game.ReplicatedStorage.GameBegins:FireClient(role)
		end
			
		end
	end
	
end
game.Players.PlayerRemoving:Connect(function(p)
for i, v in pairs(piwt) do
	if v == p then
		table.remove(piwt,i)
	end
end
for i, v in pairs(pig) do
	if v == p then
		table.remove(pig,i)
		end
		end
	
end)

1 answer

This is because :FireClient requires a Player Object to fire to, you can't expect :FireClient() to know which Client it's supposed to call to. By analyzing the code, I expect you wish to fire back the Player that called upon the Server. The Player Object is already given by .OnServerEvent, so simply just pass plr as the first argument:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("GameBegins")
RemoteEvent:FireClient(plr, role)

I closed your previous thread because it's against community guidelines to post requests for programs, it is also suggested that you try to exhaust all of your knowledge on researching for a fix before coming here, If you had done so, you would've figure it out by simply writing "RemoteEvent" on ROBLOX Developer Wiki, and noticed that the requirements were not met for the :FireClient() method. That information is found here

4 comments

0

oh, I thought I only had to put the first argument on the receiving end

0

It still doesn't fire tho

0

If it is not firing, it is scope is not being reached; ensure all conditionals pass, or nothing is proving false to interrupt the scope responsible for calling the RemoteEvent

0

This is not an issue with my fix.

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