I want to know if this script is safe from exploiters

First of all, this script is a script of the taser tool. I’ve completed this code and now I’m trying to apply it to a game, so I’m wondering if it’s safe from exploiters. (I don’t think it’s safe)
I am posting this because I want to get the vulnerabilities of this script and ways to improve it.

--Client
local d = false
local w = false
local plr = game.Players.LocalPlayer
local Message = require(game.ReplicatedStorage.MessageModule)
repeat wait(1) until plr.Character
--Animation
local character = plr.Character
local humanoid = character:WaitForChild("Humanoid")

local idle = script.Parent.Animations.Idle
local Fire = script.Parent.Animations.Fire
local Reload = script.Parent.Animations.Fire

local animtrack = humanoid:LoadAnimation(idle)
local animtrack2 = humanoid:LoadAnimation(Fire)
local animtrack3 = humanoid:LoadAnimation(Reload)

script.Parent.Unequipped:connect(function()
	animtrack:Stop()
	animtrack2:Stop()
	animtrack3:Stop()
end)

script.Parent.Equipped:Connect(function(mouse)
	animtrack:Play()
	mouse.Button1Down:Connect(function()
		if mouse.Target == nil then
			if d == false then
				d = true
				animtrack2:Play()
				script.Parent.Flam:FireServer()
				game.Workspace.CurrentCamera.FieldOfView = 75
				wait(0.02)
				game.Workspace.CurrentCamera.FieldOfView = 70
				wait(4)
				d = false
			else
				if w == false then
					w = true
					Message.ShowMessage(plr,"Please Wait!")
					w = false
				end
			end
			return end
		if d == false then
			d = true
			local hitp = mouse.Hit.p
			script.Parent.Bullet:FireServer(hitp)
			script.Parent.Flam:FireServer()
			animtrack2:Play()
			game.Workspace.CurrentCamera.FieldOfView = 75
			wait(0.02)
			game.Workspace.CurrentCamera.FieldOfView = 70
			local vplrh = mouse.Target.Parent:FindFirstChild("Head")
			local avplrh = mouse.Target.Parent.Parent:FindFirstChild("Head")
			if vplrh or avplrh then --idk
				if vplrh then
					if (script.Parent.Parent.Head.Position - mouse.Target.Parent.Head.Position).magnitude <= 35 then
						local vplr = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent)
						local vchar = mouse.Target.Parent
						game.ReplicatedStorage.Taser:FireServer(vplr,vchar)
					end
				end
				if avplrh then
					if (script.Parent.Parent.Head.Position - mouse.Target.Parent.Parent.Head.Position).magnitude <= 35 then
						if mouse.Target.Parent:isA("Accessory") then
							local vplr = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent.Parent)
							local vchar = mouse.Target.Parent.Parent
							game.ReplicatedStorage.Taser:FireServer(vplr,vchar)
						end
					end
				end
			end
			wait(4)
			d = false
		else
			if w == false then
				w = true
				Message.ShowMessage(plr,"Please Wait!")
				w = false
			end
		end
	end)
end)
--Server
local module = require(game.ReplicatedStorage.RagdollScript)
game.ReplicatedStorage.Taser.OnServerEvent:Connect(function(plr,vplr,vchar)
	if (plr.Character.Head.Position - vchar.Head.Position).magnitude <= 40 then
		module.Ragdoll(vchar, vplr)
		wait(4)
		module.Stand(vchar, vplr, vchar.Humanoid)
	else
		print("HaCkEr")
	end
end)
2 Likes

This post was flagged by the community and is temporarily hidden.

2 Likes

While it’s good to have debounces on the client to avoid wasting unnecessary bandwidth, your server does not have these so it can easily get spammed.

Additionally, as @GridLayout mentioned, don’t send the target player and character. Just send the target player as the server can then fetch the character with player.Character. Also make sure to check the type of the instance sent is actually a player.

4 Likes

Looks like, it is safe from exploiters.
They can’t lag the server, because you’re using remote event and you’re checking the distance.
For me, it could be impossible, to exploit this.

Spamming :FireServer(), could only lag the client.
I have been experimenting, with my friends and it was lagging, only the client.
You should have check “vplr”, if it’s not a nil.
And if vChar isn’t a nil ,but vplr is, then that means, that the client is exploiting the game.

2 Likes