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

How do I remove its gravity?

Asked by 8 years ago
wait(1)

local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local humanoid = player.Character.Humanoid 
local s = humanoid:LoadAnimation(game.StarterPack.Fireball.Animation)

Player = script.Parent.Parent  
Character = Player.Character 
Mouse = Player:GetMouse()  
usable = true
debounce = false

function onKeyDown(key) 
    if debounce == false then
      debounce = true
        key = key:lower() 
        if key == "f" and usable then 
        usable = false 
            s:Play()
            player.Character.Humanoid.WalkSpeed = 16
            wait(.73)
            local x = Instance.new("Part")
            x.TopSurface = "Smooth" 
            x.BottomSurface = "Smooth" 
            x.Shape = "Ball" 
            x.Transparency = .7
            x.BrickColor = BrickColor.new("Bright red")
            x.Size = Vector3.new(10, 10, 10)
            local z = Instance.new("Fire") 
            z.Parent = x 
            z.Size = 12 
            z.Heat = 12
            local p = Instance.new("ParticleEmitter")
            p.Parent = x
            p.Texture = 'http://www.roblox.com/asset/?id=357461316'
            p.Lifetime = NumberRange.new(.5,1)
            p.Size = NumberSequence.new(5)
            p.Transparency = NumberSequence.new(.5)
            p.Rate = 50
            local b = Instance.new("BodyForce")
            b.Force = Vector3.new(0,0,0)
            local y = Instance.new("BodyVelocity") 
            y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
            y.velocity = Character.Torso.CFrame.lookVector*80
            y.Parent = x  
            x.Parent = game.Workspace 
            x.CFrame = Character.Torso.CFrame*CFrame.new(0, 0, -12)
            x.Touched:connect(function(hit)
                if hit.Parent:FindFirstChild("Humanoid") then
                    hit.Parent.Humanoid:TakeDamage(20)
                    if x then 
                        x:Destroy()
                    end
                end
            end)

            wait(3.5)
            x:remove()
        wait(.6) 
        usable = true 
            end
     debounce = false
    end
 end

Mouse.KeyDown:connect(onKeyDown)

I tried to use BodyForce, I put it on 0,0,0 to give it 0 gravity so the brick won't spawn under the terrain I'm standing on. But the brick still has gravity and still spawns under the terrain. How do I fix?

1 answer

Log in to vote
3
Answered by
P100D 590 Moderation Voter
8 years ago

First of all, you might want to set the part's position manually. "Removing gravity" on the part won't stop it from spawning under the terrain.

Second, setting a BodyForce of 0,0,0 does literally nothing. What you need to do is have the BodyForce push upwards to counter gravity. Here's what you're going to have to set it to:

--Make sure to define BodyForce and part first
BodyForce.force = Vector3.new(0, 196.2, 0) * part:GetMass()
Ad

Answer this question