Hi all!... Fairly new to Roblox Lua here (but not a stranger to coding in other languages)...
I'm simply trying to use BodyForce to slow the rate at which a player... not 100% certain I'm going about this correctly, but is what I've come up with thus far after some reading and messing around... everything executes, but the player still falls like a rock :)
Thanks y'all!!
local PlayersService = game:GetService("Players")
local LocalPlayer = PlayersService.LocalPlayer
local Character = ((LocalPlayer.Character and LocalPlayer.Character.Parent) and LocalPlayer.Character) or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local ToolEquipped = false
local TotalMass = 0
local Tool = LocalPlayer.Backpack:FindFirstChild("MyTool")
Tool.Equipped:Connect(function(mouse)
print("Tool equipped")
ToolEquipped = true
for _, part in pairs(Character:GetChildren()) do
if part:IsA("Part") then
TotalMass += part:GetMass()
end
end
end)
Tool.Unequipped:Connect(function(mouse)
print("Tool unequipped")
ToolEquipped = false
TotalMass = 0
end)
local function CreateBodyForce(Character)
if ToolEquipped then
local Hum = Tool.Parent:FindFirstChild("Humanoid")
print("Cool, the Tool is equipped")
if Hum then
local Force = -196.2 * TotalMass
local BodyForce = Instance.new("BodyForce")
BodyForce.Force = Vector3.new(0, Force, 0)
BodyForce.Parent = Character.HumanoidRootPart
end
end
end
Humanoid.StateChanged:Connect(function(old,new)
print("evaluating state change")
if Humanoid.FloorMaterial == Enum.Material.Air then
print("reached state change")
local floor = Humanoid.FloorMaterial
print("Floor is: ",floor)
CreateBodyForce(Character)
end
end)

3 comments
No offence, but this comment was not particularly helpful... if you have a look at the code, you'll see that I'm attempting to change the fall rate when a tool is equipped... not for the entire workspace :)
i think you made an error at local character as there is an extra (
If you look closely, that isn't actually an 'extra' brace... "((LocalPlayer.Character and LocalPlayer.Character.Parent) and LocalPlayer.Character)" OR "LocalPlayer.CharacterAdded:Wait()"