I am trying to reset a player list that I made that contains buttons of each player. I used a remote function to destroy all the player buttons in each players player-GUI in order to reset it.

Here is the script:

destroyButtons = game.ReplicatedStorage.DestroyButtons
players = game.Players:GetPlayers()

local function destroy()
	for i = 1, #players do
		local frame = players[i]:FindFirstChild("PlayerGui"):FindFirstChild("AskAdmin").Players
		local children = frame:GetChildren()
		for k = 1, #children do
			if children[k].ClassName == "TextButton" then
				children[k]:Destroy()
			end
		end
	end
	
	print("Buttons destroyed")
end

destroyButtons.OnServerInvoke = destroy

4 comments

0

at the end of the function, wouldn't you use () instead of =? i might be wrong but with most functions i've done it ends with a () with a parameter inside

0

Thats not how remote functions work

0

Is this a server script or local script?

0

Its a server script