How can I make my gun less exploitable

Hey, I’m just wondering how I could make my gun less exploitable so Exploiters cant fire the event connecting it with a players humanoid! Any help is appreciated :smiley:

ServerScript:
local Remote = script.Parent:WaitForChild("ActivateGun")
local Sound = script.Parent.Bolt:WaitForChild("GunShot Sound")
local Damage = 100

local function OnShot(Player, Target)
	Sound:Play()
	if Target and Target.Parent then
		local Human = Target.Parent:FindFirstChild("Humanoid")
		if Human then Human:TakeDamage(Damage)
		end
	end
end

Remote.OnServerEvent:Connect(OnShot)

LocalScript:
local Tool = script.Parent
local RemoteEvent = script.Parent:WaitForChild("ActivateGun")
local Player = nil
local Mouse = nil
local Activation = nil

local function OnActivated()
	RemoteEvent:FireServer(Mouse.Target)
end

local function OnUnEquipped()
	Player = nil
	Mouse = nil
	Activation = nil
end

Tool.Equipped:Connect(function()
	Player = game:GetService("Players").LocalPlayer
	Mouse = Player:GetMouse()
    Activation = Tool.Activated:Connect(OnActivated)
end)

Is the debounce purely local? Also add server-side checks, like debounces, raycast checking (so that they arent firing at someone that isnt visible), etc…

2 Likes

Yes, there will be a debounce and I’ll use raycasting also thanks for the suggestions! :smiley:

1 Like

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