Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make this so it only works when I am in the water?

Asked by 9 years ago

I want this script to only work when I am actually in the water so I can jump and walk normally when I am not in the water.

local lolo=game:service("RunService");
local sealevel=0



function Jump(character)
local B=character.Torso.Floater
if character.Torso.Position.y<sealevel then
local v=Instance.new("BodyVelocity")
v.Parent=character.Torso
v.velocity=Vector3.new(0,30,0)
v.maxForce=Vector3.new(0,100000000,0)
wait(.4)
v:remove()
end
end




while true do
sealevel=script.Parent.Position.y
for i,v in pairs(game.Players:GetChildren()) do
if v.Character~=nil and v.Character:FindFirstChild("Torso")~=nil then
local Torso=v.Character.Torso
if Torso:FindFirstChild("Smoke")==nil then
local s=Instance.new("Smoke")
s.Parent=Torso
s.Color=Color3.new(0,0.4,0.6)
s.Opacity=0
s.RiseVelocity=0
s.Size=0.5
end
if Torso:FindFirstChild("Floater")==nil then
local B=Instance.new("BodyPosition")
B.Parent=Torso
B.position=Vector3.new(0,0,0)
B.maxForce=Vector3.new(0,0,0)
B.P=400
B.D=200
B.Name="Floater"
v.Character.Humanoid.Changed:connect(function(val) if val=="Jump" and v.Character.Humanoid.Jump==true then Jump(v.Character) v.Character.Humanoid.Jump=false  end  end)
end
local ypos=Torso.Position.y
local B=Torso.Floater
if ypos<sealevel then
Torso.Smoke.Opacity=0.2
B.position=Vector3.new(0,sealevel-1,0)
B.maxForce=Vector3.new(0,100000,0)
v.Character.Humanoid.WalkSpeed=8
v.Character.Humanoid.Health=v.Character.Humanoid.Health-2
else
Torso.Smoke.Opacity=0
local B=Torso.Floater
B.maxForce=Vector3.new(0,0,0)
v.Character.Humanoid.WalkSpeed=12
end
end
end
wait(.2)
end



0
There's an event fired when the humanoid enters the water. I think it's humanoid.Swimming:connect(function() not too sure. Just search up humanoid in roblox wiki and find it's events. ObscureEntity 294 — 9y

Answer this question