Error when firing event

My script is trying to fire a event from the server to the client to know when to tween a UI, but it is looking for a player arg, but I don’t have one nor need one for my script, is there any work around?

Part of my server sided code:

local AlivePlrs = {}
	
	for i, player in pairs(game.Players:GetPlayers()) do
		if player then
			table.insert(AlivePlrs, player)
		end
	end
	
	wait(3)
	
	local CurrentMaps = Maps:GetChildren()
	
	local ChosenMap = CurrentMaps[math.random(1,#CurrentMaps)]
	
	TweenEvent:FireClient()
	
	
	wait()
	
	Status.Value = "Starting the round..."
	

Client code:



local Status = game.ReplicatedStorage:WaitForChild("Status")

local TweenEvent = game.ReplicatedStorage.RemoteEvents:WaitForChild("Tween")

local MainUI = script.Parent.Parent

script.Parent.Text = Status.Value



Status.Changed:Connect(function()
	
	script.Parent.Text = Status.Value
	
end)

TweenEvent.OnClientEvent:Connect(function()
	
	MainUI:TweenSizeAndPosition(UDim2.new(1,0, 1,0),UDim2.new(0,0, 0,0))
	
	if Status.Value == "Setting up the round" then
		MainUI:TweenSizeAndPosition(UDim2.new(0.462,0, 0.083,0),UDim2.new(0.269,0, 0.027,0))
	end
	
	
end)

Use Remote:FireAllClients() instead. FireClient requires player argument and would fire client only for that player, in your case, you want everyone to see it.

1 Like

Thank you!!! I forgot that existed!

Sounds like WhitexHat offered the best solution for your case. However, if in the future you needed to alert a specific group of people (e.g. a team, or everyone still alive in the match) you would iterate over a specific array of players, and fire each client within the loop.

local players = {}
for _,player in next,game.Players:GetPlayers() do
    if some_conditional then -- are they on a team? alive? dead? your conditional here
        TweenEvent:FireClient(player)
    end
end

Hmm. Good suggestion, although I don’t think that is necessary in this case, it is just a game transition