so i have this script which makes the player casually sit. simple. the problem is that this is used for one of those fall in balls thing. just basically falling with alot of objects you bumb into. the thing is this happens really fast and you fall mega fast so the fun is over fast, i was wondering if it was possible to make it that as long as your sitting maybe your gravity or falling speed is slower? i dont know.
print("Sit script working")
brick = script.Parent
function OnTouched(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then
humanoid.Sit = true
end
end
script.Parent.Touched:connect(OnTouched)
1: does this only implie when using this script because its only one part of the game and i dont want the rest to be weirdly gravitated. 2: can you insert it into the script?
You only need to apply force on the Y axis. You don’t need to do it on the other axes. You may also need to account for the masses of their other body parts and accessories, since they have mass too (i.e. Massless property is false).
This can be used:
local character = humanoid.Parent
local totalMass = 0
for _, part in pairs(character:GetDescendants()) do
if part:IsA("BasePart") and (not part.Massless) then
totalMass = totalMass + part:GetMass()
end
end
local a = 150 --[[ acceleration upwards
Roblox's gravitational acceleration is 196.2 by default, if you haven't changed it
You want a to be less than the gravitational acceleration for the player to still be falling
--]]
local force = totalMass * a
bodyForce.Force = Vector3.new(0, force, 0)
Also, considering that all matter (even atoms) has their own gravitational pull, you could assume that each part of the player has their own gravitational pull and they have different forces due to the difference in their mass and those add up to get the total weight (gravitational pull). This is why you have to account for the masses of all the other parts of their character
This would go along with the block of the if statement, so you will just put the code in the if statement:
function OnTouched(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then
humanoid.Sit = true
local character = humanoid.Parent
local totalMass = 0
for _, part in pairs(character:GetDescendants()) do
if part:IsA("BasePart") and (not part.Massless) then
totalMass = totalMass + part:GetMass()
end
end
local a = 150 --[[ acceleration upwards
Roblox's gravitational acceleration is 196.2 by default, if you haven't changed it
You want a to be less than the gravitational acceleration for the player to still be
falling
--]]
local force = totalMass * a
bodyForce.Force = Vector3.new(0, force, 0)
end
end
script.Parent.Touched:connect(OnTouched)
And no, this won’t affect other players’ or the game’s gravitational pull. After the player lands, you can remove the BodyForce
Forgot to instantiate the BodyForce and set its parent:
local bodyForce = Instance.new("BodyForce")
local force = totalMass * a
bodyForce.Force = Vector3.new(0, force, 0)
bodyForce.Parent = character.HumanoidRootPart
Btw, I implore you to check the output before asking again here – you would’ve seen an error in the output because the bodyForce wasn’t created yet
brick = script.Parent
function OnTouched(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then
humanoid.Sit = true
workspace.Gravity = 100 --Change it to the number that suits you.
end
end
script.Parent.Touched:connect(OnTouched)
but then i was thinking another part to revert the gravity back to normal but then people would get up and stand in the middle of the fall and then use the less gravity to cheat things
Oh, so you’re worried that normal people will touch it and it will revert?
Maybe in the same script create a table of the players who touched, and then check if they touch it.
Do you have multiple parts that need to fall slow or only the player?
Oh, then that’s not a problem, just make a local script that checks if the part is touched, in a place that it works, and check if the local player is the player that touched. If it is , change/revert the gravity, that way only 1 player’s gravity will change, and if one player touches the part it won’t affect other players.
function OnTouched(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then
humanoid.Sit = true
local character = humanoid.Parent
local totalMass = 0
for _, part in pairs(character:GetDescendants()) do
if part:IsA("BasePart") and (not part.Massless) then
totalMass = totalMass + part:GetMass()
end
end
local a = 150 --[[ acceleration upwards
Roblox's gravitational acceleration is 196.2 by default, if you haven't changed it
You want a to be less than the gravitational acceleration for the player to still be
falling
--]]
local bodyForce = Instance.new("BodyForce")
local force = totalMass * a
bodyForce.Force = Vector3.new(0, force, 0)
bodyForce.Parent = character.HumanoidRootPart
end
end
script.Parent.Touched:connect(OnTouched)