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

How do i make this script not lag my game and create a memory leak?

Asked by 1 year ago

This is a vault script for my parkour game bt its making some kind of memory leak wich is lagging my game. Please help

--Vault System

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local HRP = char:WaitForChild("HumanoidRootPart")
local Hum = char:WaitForChild("Humanoid")
local CA = Hum:LoadAnimation(script:WaitForChild("ClimbAnim"))

local ledgeavail = true

topspeed = 20
char.Humanoid.Running:Connect(function(speed)

    if speed > topspeed then
        ledgeavail = true
    elseif speed < topspeed then
        ledgeavail = false
    end






while game:GetService("RunService").RenderStepped:Wait() do
     r = Ray.new(HRP.Position, HRP.CFrame.LookVector * 6.5 + HRP.CFrame.UpVector * -5)
    local part = workspace:FindPartOnRay(r,char)

    if part and ledgeavail then
        if part.Name == "Vault" then
                if Hum.FloorMaterial ~= Enum.Material.Air then
                    if speed < topspeed then
                ledgeavail = false
                local Vel = Instance.new("BodyVelocity")
                Vel.Parent = HRP
                Vel.Velocity = Vector3.new(0,0,0)
                Vel.MaxForce = Vector3.new(1,1,1) * math.huge
                Vel.Velocity = HRP.CFrame.LookVector * 60 + Vector3.new(0,28,0)
                CA:Play()
                game.Debris:AddItem(Vel, .10)
                        wait(0.75)

                        ledgeavail = true
                        game.Debris:Destroy(Vel)
            end
        end
    end
    end
    end
    end)
0
get rid of the loop from the event greatneil80 2647 — 1y
0
game:GetService("RunService").RenderStepped:Connect()? Puppynniko 1059 — 1y
0
could you post an answer please? imnew to this 123marooxd123 13 — 1y

1 answer

Log in to vote
0
Answered by
enes223 327 Moderation Voter
1 year ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Ad

Answer this question