I want to make an un laggy taser, it’s not laggy when the other person hasn’t moved at all but starts to lag when tasing someone when the other person has moved.
I’ve tried reducing the rope thickness and most things like that.
local event = script.Parent.TaserEvent
local ReloadingEvent = script.Parent.ReloadingEvent
local tool = script.Parent
local player = script.Parent.Parent.Parent
local Isfired = false
event.OnServerEvent:Connect(function(plr, target)
if target.Parent:FindFirstChild("Humanoid") and Isfired == false and script.Parent.Ammo.Value == 1 then
if (target.Position - plr.Character.HumanoidRootPart.Position).Magnitude <= 15 then
Isfired = true
script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
local Att1 = Instance.new("Attachment")
Att1.Parent = target
local Att2 = Instance.new("Attachment")
Att2.Parent = target.Parent.Torso
local Rope1 = Instance.new("RopeConstraint")
Rope1.Length = 18
Rope1.Color = BrickColor.new("Institutional white")
Rope1.Parent = script.Parent.Cart
Rope1.Attachment0 = script.Parent.Cart.TaserRope1
Rope1.Attachment1 = Att1
Rope1.Visible = true
Rope1.Thickness = 0.009
Rope1.Name = "Rope1"
local Rope2 = Instance.new("RopeConstraint")
Rope2.Length = 18
Rope2.Color = BrickColor.new("Institutional white")
Rope2.Parent = script.Parent.Cart
Rope2.Attachment0 = script.Parent.Cart.TaserRope1
Rope2.Attachment1 = Att2
Rope2.Visible = true
Rope2.Thickness = 0.009
Rope2.Name = "Rope2"
target.Parent.Humanoid.PlatformStand = true
script.Parent.Handle.Sound1:Play()
wait(0.5)
script.Parent.Handle.Sound2:Play()
wait(5)
local FindRope1 = script.Parent.Cart:FindFirstChild("Rope1")
if FindRope1 then
FindRope1:Destroy()
end
local FindRope2 = script.Parent.Cart:FindFirstChild("Rope2")
if FindRope2 then
FindRope2:Destroy()
end
target.Parent.Humanoid.PlatformStand = false
Isfired = false
end
end
end)
tool.Unequipped:Connect(function(plr, target)
local FindRope1 = script.Parent.Cart:FindFirstChild("Rope1")
if FindRope1 then
FindRope1:Destroy()
end
local FindRope2 = script.Parent.Cart:FindFirstChild("Rope2")
if FindRope2 then
FindRope2:Destroy()
end
Isfired = false
if script.Parent.Handle.Sound2.Playing == true then
script.Parent.Handle.Sound2:Stop()
end
if script.Parent.Handle.Sound1.Playing == true then
script.Parent.Handle.Sound1:Stop()
end
end)
ReloadingEvent.OnServerEvent:Connect(function()
local FindRope1 = script.Parent.Cart:FindFirstChild("Rope1")
if FindRope1 then
FindRope1:Destroy()
end
local FindRope2 = script.Parent.Cart:FindFirstChild("Rope2")
if FindRope2 then
FindRope2:Destroy()
end
Isfired = false
if script.Parent.Handle.Sound2.Playing == true then
script.Parent.Handle.Sound2:Stop()
end
if script.Parent.Handle.Sound1.Playing == true then
script.Parent.Handle.Sound1:Stop()
end
if script.Parent.Ammo.Value == 0 and script.Parent.Maxammo.Value >= 0 then
script.Parent.Handle.Sound3:Play()
script.Parent.Maxammo.Value = script.Parent.Maxammo.Value - 1
script.Parent.Ammo.Value = script.Parent.Ammo.Value + 1
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.