Is there a better way to use RemoteEvents for different teleport door scripts?

  1. 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

  2. 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)

v What the scripts does in game v
https://i.gyazo.com/96b19a6fb9c1a7a7406cb94e4a88bbc4.mp4

  1. Could’nt think of anything that would improve this without having to change how the door system works and I wanna keep this system?

I’m just wondering if the way im doing this is gonna be efficient in the long term cause im gonna be adding more building just like this!

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)
2 Likes

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