-
What do you want to achieve? I want to fix my character sinking when going below a certain height in my game.
-
What is the issue? I’ve tried adjusting stuff like density of character, but that doesn’t work.
-
What solutions have you tried so far? I checked on the developer hub, YouTube, and ChatGPT.
Video please, I have no clue what you’re talking about
A simple fix would be to add a transparent CanCollide true Part at that level.
What Density did you adjust all the Player’s Parts to? Less than 1 will float and greater than 1 will sink. When you test click on individual player’s Parts in the workspace (not the Player’s folder) to see what they are in game.
Don’t mind the last part
I put all of them to .5 at first, then tried .25, then .1, then .01.
you will probably need to add a force to make the player go up again lol
You can have some code to add a BodyForce to the character to counter gravity when they go below a certain height.
Here is some code to go in a LocalScript in StarterCharacterScripts:
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local character = script.Parent
local hrp = character:WaitForChild("HumanoidRootPart")
local bf = Instance.new("BodyForce")
bf.Parent = hrp
bf.Enabled = false
local height = -5
local connection
connection = RunService.Heartbeat:Connect(function()
-- Stop checking if the current character died or was destroyed
if not hrp:IsDescendantOf(Workspace) then
bf:Destroy()
connection:Disconnect()
end
if character:FindFirstChild("Humanoid") and character.Humanoid.Health <= 0 then
bf:Destroy()
connection:Disconnect()
end
-- Activate the force based on whether the character is above or below the height
if hrp.Position.Y < height then
if not bf.Enabled then
local gravForce = Workspace.Gravity * hrp.AssemblyMass
bf.Force = Vector3.new(0, gravForce, 0)
bf.Force.Enabled = true
end
else
bf.Enabled = false
end
end)
BodyForce is technically depreciated but it’s way simpler to code and Roblox will keep it for a while so yeah. You can always ask GPT to switch it to a VectorForce.
If you want the player to float up when below the height you can increase the force (i.e mass * gravity * 1.05).
Yes, but I asked if you tried it while testing.
Did the values stay, or did the player’s parts reset to their normal values.
I’ve heard that player’s Properties need to be set every frame in game, otherwise they go back to their normal values.
Would a transparent CanCollide Part solve your issue?
I guess. Instead of a cancollide invisible part, I think I’m just gonna move up the oceanfloor.
Your character has a sword in their hand - is Massless
checked for all the parts of the sword?
Yeah, that’s the first thing I tried.
I’m not sure, but this information about how my water works might help. It has a water part and it is cancollide off, invisible, and simply moves to the player to fill water there.
You answered about the CanCollide part.
In my posts I’ve asked more than just one question in each of them but you’ve only replied with one answer.
You still haven’t answered my questions about checking the actual Density of the player’s Parts WHILE you are play testing.
I did check it while testing, and they still are low.
I know it isn’t the density too since it only drags you down when you’re below a certain point.