I am working on a submarine game, where you explore the underwater sea life, and I am coding the submarine.
Whenever you enter and leave the submarine, it fires the client to enable/disable the swimming state.
Enabling it works, but when i enter back into the submarine, it doesn’t disable it, and I can swim freely inside the submarine.
--Client
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid
humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming,false)
game.ReplicatedStorage.inside.OnClientEvent:Connect(function(value)
print(value)
if value == true then
humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming,false)
else
humanoid:SetStateEnabled(Enum.HumanoidStateType.Swimming,true)
end
end)
--Server
script.Parent.door.ProximityPrompt.Triggered:Connect(function(player)
game.ReplicatedStorage.inside:FireClient(player,false)
player.Character:PivotTo(script.Parent.door2.CFrame)
end)
script.Parent.door2.ProximityPrompt.Triggered:Connect(function(player)
game.ReplicatedStorage.inside:FireClient(player,true)
player.Character:PivotTo(script.Parent.door.CFrame)
end)