I made a skill move and whenever i press F i lag and the output has too many errors but not really an error to me, they are normal. But it was then i put wait() to Explosion:Destroy() So i really need help out there. and i don't know the reason why i lag and it might be the script. Need help just give me a little hint.
script.Parent.OnServerEvent:Connect(function(plr)
local Slash = game.ReplicatedStorage.Skill.SPPTS:Clone()
Slash.Parent = workspace
Slash.CanCollide = false
Slash.Anchored = false
Slash.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(1,0,3) * CFrame.fromEulerAnglesXYZ(4.7,1.6,14.1)
Slash.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= plr.Name then
local Explosion = game.ReplicatedStorage.Skill.SPPTS:Clone()
Explosion.Parent = workspace
Explosion.CFrame = Slash.CFrame
Explosion.CanCollide = false
Explosion.Anchored = true
Slash:Destroy()
hit.Parent.Humanoid:TakeDamage(0)
for i = 1,18 do
wait(.05)
Explosion.Size = Explosion.Size + Vector3.new(3,3,3)
Explosion.Transparency = Explosion.Transparency + 0
Explosion.Touched:connect(function(part)
local debounce = true
local Humanoid = part.Parent:findFirstChild('HumanoidRootPart')
if Humanoid then
debounce = false
Humanoid.Anchored = true
wait(0.1)
debounce = true
local owner = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("HumanoidRootPart")
owner.Anchored = false
wait(5)
Humanoid.Anchored = false
else
if not Humanoid then
debounce = true
local function remove(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if humanoid and player then
local inHand = otherPart.Parent:FindFirstChildWhichIsA('Tool')
local inBackpack = player.Backpack:FindFirstChildWhichIsA('Tool')
if inHand then
inHand.Enabled = false
inHand.Archivable = false
inHand.ManualActivationOnly = false
humanoid:UnequipTools()
wait(0.1)
local ownertool = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild('Humanoid')
ownertool:Equip()
end
if inBackpack then
inBackpack.Enabled = false
inBackpack.Archivable = false
inBackpack.ManualActivationOnly = false
humanoid:UnequipTools()
local ownertool = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild('Humanoid')
ownertool:Equip()
local tool = script.Parent.Parent.Parent.Parent
tool:Deactivate()
end
end
end
wait(5)
Explosion.Touched:Connect(remove)
end
end
end)
end
Explosion:Destroy()
end
end)
local BV = Instance.new("BodyVelocity",Slash)
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 80
wait(0.055)
Slash:Destroy()
end)
Other script that will let me press F:
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Debounce = true
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.F and Debounce == true then
Debounce = false
script.RemoteEvent:FireServer(plr)
script.RemoteEvent2:FireServer(plr)
wait(5)
Debounce = true
end
end)

6 comments
Uhm, this is not very friendly to read, whats the errors, and i cant see what line it is that activates a function when you press F
only post the lines that have errors, we cant debug the whole 77 line script and see which ones are faulty without knowing the errors and not knowing the positions of each object
Normally, I'd say it would be fine to debug something 77 lines, but here, you've changed and messed up the default indentations in your source decreasing the readability by a lot. Not only that, but it's a ton of nested conditionals, and you could have broken this down into functions to make it easier for yourself.
You also failed to include your local script.
ok hold up im editing chill out
back there done.