Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to stop exploiters from firing this remote event? please help!

I have this script that spawns cars, so some exploiters keep firing this remote event that causes a lot of cars to spawn on the map, and makes the game laggy, what do I need to do? please help.

Local Script(On Gui):

local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnCarEvent = ReplicatedStorage:WaitForChild("sw")
local DeleteCarEvent = ReplicatedStorage:WaitForChild("ac")
local carName = script.Parent.Name
local SpawnCarFrame = script.Parent.Parent

script.Parent.MouseButton1Down:Connect(function()
	SpawnCarFrame.Visible = false
	local CurrentCar = game.Workspace:FindFirstChild(player.Name .. 'sCar')
	if not CurrentCar then
    SpawnCarEvent:FireServer(carName)
	else
		if player.Character.Humanoid.SeatPart ~= nil and player.Character.Humanoid.SeatPart:IsA("VehicleSeat") then
			player.Character.Humanoid.Sit = false
		end
		wait()
		DeleteCarEvent:FireServer(CurrentCar)
		SpawnCarEvent:FireServer(carName)
	end
end)

Script(ServerScriptService):

local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnCarEvent = ReplicatedStorage:WaitForChild("sw")
local DeleteCarEvent = ReplicatedStorage:WaitForChild("ac")

SpawnCarEvent.OnServerEvent:Connect(function(player, carName)
	local Car = ServerStorage:FindFirstChild("Cars"):FindFirstChild(carName)
	if Car then
		local clonedCar = Car:Clone()
		clonedCar.Name = player.Name .. 'sCar'
		clonedCar.Parent = game.Workspace
		clonedCar:MoveTo(player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame.LookVector * 15)
	end
end)

DeleteCarEvent.OnServerEvent:Connect(function(player, Car)
	if Car then
		Car:Remove()
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local Car = game.Workspace:FindFirstChild(player.Name .. 'sCar')
	if Car then
		Car:Remove()
	end
end)

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local Car = game.Workspace:FindFirstChild(player.Name .. 'sCar')
		if Car then
			Car:Remove()
		end
	end)
end)

1 answer

You could add something like

if workspace:FindFirstChild(player.Name .. 'sCar') then return end

This will check if the player already has a car. If they do, the script will return

6 comments

0

umm this can stop exploit from firing event alot? like they use script like : game.replicatedstorage.RemoteEvent:Fire

0

A way to stop exploiters from firing the event a lot is to add a server-sided cooldown.

0

can u make one? im new to this things.

0

scripting helpers is not a request website

0

"can u make one" yeah

0

aight if u can make it, im accepting ur answer!

This discussion is preserved as it was. New answers, comments, and votes are closed.