Im wondering if its a good idea if my game has like 30 remote events, 2 for each floor leaving and entering since each door has different requirements of who can enter
Im wondering if using this many Remote Events could cause severe vunerabilities with the game that could be easily exploited I did add a wait(1) in the scripts but idk if that will prevent remote spam or not
v DoorTrigger RemoteEvent Local Script in StarterCharacterScripts v
local triggerdoor = game:GetService("ReplicatedStorage"):WaitForChild("TriggerDoor")
local triggerdoor1 = game:GetService("ReplicatedStorage"):WaitForChild("TriggerDoor1")
local player = game.Players.LocalPlayer
--Enter Group Tower
triggerdoor.OnClientEvent:Connect(function()
local role = player:GetRoleInGroup(3796342)
print(player.Name.." is "..role)
local rank = player:GetRankInGroup(3796342)
print(player.Name.." is "..rank)
if rank >= 1 then
print(player.Name.." can enter!")
local hum = player.Character:FindFirstChild("Humanoid")
if hum ~= nil then
player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TPrecievers.GrTowerFl1Atp.Position)
end
elseif rank == 0 then
print(player.Name.." Can not enter..")
end
end)
--Exit Group tower
triggerdoor1.OnClientEvent:Connect(function()
player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TPrecievers.GrTowerFl1Btp.Position)
end)
v Door Enter Script v
local triggerdoor = game:GetService("ReplicatedStorage"):WaitForChild("TriggerDoor")
local proximityprompt = script.Parent
proximityprompt.Triggered:Connect(function(player)
triggerdoor:FireClient(player)
wait(1)
end)
v Door Exit Script v
local triggerdoor1 = game:GetService("ReplicatedStorage"):WaitForChild("TriggerDoor1")
local proximityprompt = script.Parent
proximityprompt.Triggered:Connect(function(player)
triggerdoor1:FireClient(player)
wait(1)
end)
The Door Enter Script and Door Exit Script’s wait(1) is useless, as events aren’t ran in order. If you want to make sure it cant be spammed, add a debounce with tick()
People can still spam it by firing from exploit scripts, so there’s no easy way to stop it realistically
You should do the Rank and Role checking from a server script as well, as people can spoof it from local scripts.
If you did this, you wouldn’t need remote events at all, because you could do everything on the server. Here’s some code samples of how you could do that
v Door Enter Script v
local proximityprompt = script.Parent
proximityprompt.Triggered:Connect(function(player)
local role = player:GetRoleInGroup(3796342)
print(player.Name.." is "..role)
local rank = player:GetRankInGroup(3796342)
print(player.Name.." is "..rank)
if rank >= 1 then
print(player.Name.." can enter!")
local hum = player.Character:FindFirstChild("Humanoid")
if hum ~= nil then
player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TPrecievers.GrTowerFl1Atp.Position)
end
elseif rank == 0 then
print(player.Name.." Can not enter..")
end
end)
v Door Exit Script v
local proximityprompt = script.Parent
proximityprompt.Triggered:Connect(function(player)
player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TPrecievers.GrTowerFl1Btp.Position)
end)
You could do it in one script as well!
v Door Script v
local enterproximityprompt = script.Parent.Enter -- Whatever your enter prompt is named
local exitproximityprompt = script.Parent.Exit -- Whatever your exit prompt is named
-- Declare enter and exit functions --
local function enter(player)
local role = player:GetRoleInGroup(3796342)
print(player.Name.." is "..role)
local rank = player:GetRankInGroup(3796342)
print(player.Name.." is "..rank)
if rank >= 1 then
print(player.Name.." can enter!")
local hum = player.Character:FindFirstChild("Humanoid")
if hum ~= nil then
player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TPrecievers.GrTowerFl1Atp.Position)
end
elseif rank == 0 then
print(player.Name.." Can not enter..")
end
end
local function exit(player)
player.Character.HumanoidRootPart.CFrame = CFrame.new(workspace.TPrecievers.GrTowerFl1Btp.Position)
end
-- Prompt Handling --
enterproximityprompt.Triggered:Connect(enter)
exitproximityprompt.Triggered:Connect(exit)