RemoteEvent simply won't work

I’m making a script where I simply click a button, and the server shuts down, but it doesn’t work?
(if you are worried about exploiters, they cannot fire to all clients and the button only becomes visible with my userid)

Button Script
local Players = game:GetService("Players")
local LocalPlay = Players.BlueClothesPerson
local Button = script.Parent

Button.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.ShutAbility:FireAllClients()
end)
RemoteEvent
local Event = game.ReplicatedStorage.ShutAbility

Event.OnServerEvent:Connect(function(Caller)
	if Caller.UserId == game.CreatorId then
		for _, Player in pairs(game.Players:GetPlayers()) do
			local m = Instance.new("Message")
			m.Parent = game.Workspace
			m.Text = "⚠ This server is going to close in 5 SECONDS ⚠"
			wait(5)
			Player:Kick("server shut down")
		end
	end
end)

If (somehow) you are able to make the TextButton to be able to change the kick reason, that would be great!
(not needed though)

You can’t fire an RE to other clients as a client yourself, instead you have to use the server as a middleman to communicate with all other clients i.e fire the RE to the server who then fires it to all clients except the player who fired the event

Anything on the client side can be modified by exploiters. This alsp includes modifying the state of UI such as making them visible, changing their transparency etc. The best way to secure this is to have the server validate that the player who fired the RE has the perms to do so and then only continue with the process.

Also If you wanna play it strict you can also kick/ban the player if he doesn’t have the perms provided that the gui isn’t accessible to all. ((ignore the strike through text cuz i didnt see your server script before typing it*)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.