Hi, what I want to achieve is so you stay still underwater until you want to swim again. My problem is that you always float back up and we don’t want that. We tried using this script below and try changing the gravity but that doesn’t seem to work. Please help us if you can!
Hi, what I want to achieve is so you stay still underwater until you want to swim again. My problem is that you always float back up and we don’t want that. We tried using this script below and try changing the gravity but that doesn’t seem to work. Please help us if you can!
That didn’t work for some reason
By any chance could you look at our game to see whats the problem and maybe fix it? If your available we have payment
Really sorry for disturbing you, but did you find the solution yet?
Hello turtle! Try putting this script inside a local script under starter playerscripts and set the value of density to a desirable point, I figured that for my workspace 0.95 was the most suitable threshold since my char neither sinked nor rose up at that value, but feel free to change that value as you may.
Goodluck and God speed with your game
--Script by Phantom
local density = 0.95 --fix the density to a desired amount
game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
print("char added")
char:WaitForChild("HumanoidRootPart")
local parts = char:GetDescendants()
for _,desc in pairs(parts) do
if desc:IsA("BasePart") then
print(desc.Name)
desc.CustomPhysicalProperties = PhysicalProperties.new(density,0.5,1,0.3,1)
end
end
end)
I’ll try it first thing tomorrow and let you know! Thank you so much, and if not is there anyway I could contact you to maybe see if you could make it work? We have payment
Ye, sadly it didn’t work. It just makes me sink. I could set it to make me stay floating but other peoples avatars would sink or float so how would I fix it to make everyone stay underwater?
I asked this same thing a few days ago, with no answer found.
Yeah I think I can do that! Contact me in PMs if you haven’t fixed the issue.
Hmmmm, there’s another workaround for this, you could try anchoring the player’s root part when there’s no received input from the user, but that’s quite hacky and not as smooth as one would expect, neither would that be console friendly…
Another way would be to search the forums for the density required to float in water and change it so that only the root part changes density.
I’ll try the second method and update you if I find any answers!
My script below solves the problem and calculates density for every user according to their character, but since I didn’t have time I wasn’t able to clean up the script a lot, so I’ll post a better versioned script soon, but for now this will have to suffice…
The script waits till the player jumps into water (humanoid state type) and then starts calculating the velocity at which their avatar is sinking/rising and adjusts the density accordingly. As soon as a final value is obtained i.e the player avatar sinks/raises at a negligible rate, the density is finalized and baked (it calculates density for the avatar only when the player is added to the game).
Also as said before you have to upload the below script to a local script under StarterPlayerScripts
P.S.
I didn’t have time to check for glitches, so if you run into any feel free to contact me
--Script by Phantom
local threshval = 10
local crctval = 0.001
local startingdens = 1
local finaldens = 0
local function changeden(num,char)
char:WaitForChild("HumanoidRootPart")
local parts = char:GetDescendants()
for _,desc in pairs(parts) do
if desc:IsA("BasePart") then --and desc.name=="HumanoidRootPart" then
--if desc.Name ~= "Handle" then
desc.CustomPhysicalProperties = PhysicalProperties.new(num,0.5,1,0.3,1)
--end
end
end
end
local function upden(num,char)
startingdens = startingdens+num
char:WaitForChild("HumanoidRootPart")
local parts = char:GetDescendants()
for _,desc in pairs(parts) do
if desc:IsA("BasePart") then --and desc.name=="HumanoidRootPart" then
--if desc.Name ~= "Handle" then
desc.CustomPhysicalProperties = PhysicalProperties.new(startingdens,0.5,1,0.3,1)
--end
end
end
end
--------------------------------------------------------------------------------
local requirement = true
local run = game["Run Service"]
game.Players.LocalPlayer.CharacterAdded:Connect(function(char)
if requirement == false then
changeden(finaldens,char)
else
local hum = char:WaitForChild("Humanoid")
local rp = char:WaitForChild("HumanoidRootPart")
changeden(startingdens,char)
local time1 = tick() - 0
local debounce = true
local rpy = rp.Position.Y
run.RenderStepped:Connect(function()
if debounce == true and requirement == true then
debounce = false
local curt = tick()
local cury = rp.Position.Y
local vel = ((cury-rpy)/(curt-time1))
if vel>-10 and vel <10 and hum:GetState() == Enum.HumanoidStateType.Swimming then
local correctionval = (vel/math.abs(vel))*crctval
if crctval> math.abs(vel)then
requirement = false
print("corrected velocity for ".. char.Name..". Final Density = "..startingdens)
finaldens = startingdens
crctval = 0
end
upden((vel/math.abs(vel))*crctval,char)
end
rpy = cury
time1 = curt
debounce = true
if requirement == false then
changeden(finaldens,char)
end
end
end)
end
end)
I will check it out in the next day or so, thanks for the reply.
use some sort of force object on the sinking to balance it? im not quite sure