Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

whenever pressing F i lag why is that?

Asked by
lo_1003 42
4 years ago
Edited 4 years ago

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)
2
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 AmIOriginalOrNot 105 — 4y
0
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 AmIOriginalOrNot 105 — 4y
0
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. SteamG00B 1633 — 4y
0
You also failed to include your local script. SteamG00B 1633 — 4y
View all comments (2 more)
0
ok hold up im editing chill out lo_1003 42 — 4y
0
back there done. lo_1003 42 — 4y

1 answer

Log in to vote
0
Answered by
iuclds 720 Moderation Voter
4 years ago

press tab to indent

i tried helping but i couldnt read anything

0
this should be marked as a solution iuclds 720 — 4y
0
little hint can give me some help, i will read and try that.. lo_1003 42 — 4y
0
Fam, i knew it thank you bro. lo_1003 42 — 4y
0
lol iuclds 720 — 4y
Ad

Answer this question