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