The "nogravity script works fine, but glitches. I want characters to only have it in a specific building, but sometimes when I walk in I dont get the gravity decrease. So, I wanted to make a "reassurance" that the character had the "nogravity". Here's the script that gives gravity if you have and take it away if you walk back through it.

local enabled = true

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.PrimaryPart:FindFirstChild("BodyForce") and enabled then
        hit.Parent.PrimaryPart.BodyForce:Destroy()
        enabled = false
        wait(2)
        enabled = true
        return
    elseif hit.Parent:FindFirstChild("Humanoid") and enabled then
        enabled = false
        local bf = Instance.new("BodyForce")
        bf.force = Vector3.new(0,2000,0)
        bf.Parent = hit.Parent.PrimaryPart
        wait(5)
        enabled = true
    end
end)


My Goal: Make sure the player doesnt have it already, then give it to them, if they already have it, then leave them one they had.

Again, this is the script thats already in a part, but sometimes it glitches. The script works fine, but not all the time, so to make sure the player gets the nograv, I'm wondering what edits I can make to this one.

2 comments

0

Why are you posting it again? , and again, what's the glitch here?

0

im pretty sure i explained this well, but i figured it out