How would I allow a player to walk around inside water without being affected by it

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would like to make a system where I can disable swimming in water. For example, the ability to walk around in an underwater vehicle.

  2. What is the issue? Include screenshots / videos if possible!
    I am not sure what I can do to make this happen. I know that the game sharkbite has done this successfully so I know that it is possible.

I am also unable to upload the video I took of the problem from my ipad.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried setting up a collision group which makes players not collide with terrain. However this results in players just swimming along the seabed without being able to jump.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Localscript in starterplayer scripts

local plr = game.Players.LocalPlayer
local char = plr.Character() or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
hum:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)

SetStateEnabled

1 Like

Thanks, I’ll try it your suggestion.

Here is my current code

  local Debounce = false

    script.Parent.Activated:Connect(function()
    	if Debounce == false then
    		Debounce = true
    		if script.Parent.Parent:FindFirstChild("Humanoid") ~= nil then
    			if script.Parent.Parent.HumanoidRootPart.CollisionGroupId == 0 then
    				for i, part in pairs(script.Parent.Parent:GetChildren()) do
    					if part:IsA("BasePart") then
    						part.CollisionGroupId = 2
    						script.Parent.Parent.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)
    					end
    				end
    			else
    				for i, part in pairs(script.Parent.Parent:GetChildren()) do
    					if part:IsA("BasePart") then
    						part.CollisionGroupId = 0
    					end
    				end
    			end
    		end
    		wait(2)
    		Debounce = false
    	end
    end)

I found a post where someone else tried this to make their submarine. This method doesn’t seem to work, any other ideas?

Sorry for the necro post, but
the solution of
hum:SetStateEnabled(Enum.HumanoidStateType.Swimming, false)
does work, its just that you need to set it on both the client and the server.

11 Likes