I've been working on a platformer, but for some reason this script lags a lot in the server.
deb=false
J1=false
J2=false
mouse=script.Parent.Parent:GetMouse()
plyr=script.Parent.Parent
repeat wait() until plyr.Character
plyr.Character.Humanoid.WalkSpeed=24
local function onKeyDown( key )
print("Key:", key, " Code:", string.byte(key))
if key==" " and plyr.Character.Torso.Velocity.Y~=0 and J1==true and plyr.Character.Humanoid.Jump==true and deb==false then
deb=true
plyr.Character.Torso.Velocity=Vector3.new(0,50,0)
script.Sound:Play()
J2=true
wait(1.1)
deb=false
end
end
mouse.KeyDown:connect(onKeyDown)
function D()
if plyr.Character.Humanoid.Jump==true then
J1=true
end
end
plyr.Character.Humanoid.Changed:connect(D)
while wait() do
if plyr.Character.Torso.Velocity.Y==0 then
J1=false
end
end
Help is appreciated.
