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

BodyPosition force is not strong enough using GetMass?

Asked by 5 years ago
-- VARIABLES



local GasLocation = script.Parent.Parent



local PlaneLocation = script.Parent.Parent.Parent.Planes



local GasChildren = script.Parent.Parent:GetChildren()



local PlaneChildren = game.Workspace.Planes:GetChildren()



local GasProp = script.Parent



local Gravity = game.Workspace.Gravity







local Debounce = false







-- VARIABLES



local function GasTouched(hit) -- This function is run whenever the gas is hit.



if not Debounce then Debounce = true -- Debounce

if GasProp.Name == "GasModel" then -- Check if the Prop is the cloning Prop.

return

end

-- VARIABLES

local PlayerTouched = hit.Parent:FindFirstChild("Humanoid") -- Player's Humanoid

local PlayerTouchedName = PlayerTouched.Parent.Name -- Player's name

-- VARIABLES

for i,v in pairs(PlaneChildren) do

if v.Name == PlayerTouchedName .. "\'s Plane" then

v.Size = v.Size + Vector3.new(1,1,1)

v.BodyPosition.MaxForce = Vector3.new( Gravity*v:GetMass(), Gravity*v:GetMass(), Gravity*v:GetMass()) -- Adjust Weight Balance

end

end

GasProp:Destroy()

wait(2)

Debounce = false -- Reset Debounce

end

end





if GasProp.Touched then

GasProp.Touched:Connect(GasTouched)

end

My problem is happening with v:GetMass()*Gravity, when the prop gets too big it is falling through the earth resulting in the prop despawning.

I know that there is probably a way simpler way of doing what I have done using smaller code but I am fairly new and this is the first time I have attempted something like this.

0
omg learn to indent pls, otherwise your never gonna be a good scripter LoganboyInCO 150 — 5y

Answer this question