I need help with a remote event for a admin UI. So I want to make a shutdown event but if a hacker can get into the admin UI they can just fire the event. So I only want to fire the event if they are a specific player. But the event still fires even when I change the userId.
Script
--Service--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local AdminEvents = ReplicatedStorage.AdminEvents
local ShutdownEvent = AdminEvents.ShutdownEvent
--
--
ShutdownEvent.OnServerEvent:Connect(function(player, userID)
if player.UserId == "1507646970" or "339310190" then
print("Player can fire the event")
else
print("Error")
end
end)
Local Script
--Service--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local userID = Players.LocalPlayer.UserId
local AdminEvents = ReplicatedStorage.AdminEvents
local ShutdownEvent = AdminEvents.ShutdownEvent
--locals--
local ShutdownButton = script.Parent.ShutdownButton
--
ShutdownButton.MouseButton1Click:Connect(function(player, userId)
ShutdownEvent:FireServer(player, userID)
end)
This will always return false because you are trying to compare a number and a string. Also, in the second condition, you forgot to compare that UserId and the player’s UserId in the if statement.
You don’t need to pass the player and UserId as arguments because by default the first parameter of the RemoteEvent.OnServerEvent event is the player that fired the RemoteEvent and you can get the UserId with the player’s UserId property.