Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you prevent jumping?

local player = game.Players.LocalPlayer
humanoid = player.Character:WaitForChild("Humanoid")
player.CameraMode = "LockFirstPerson"
player.CameraMaxZoomDistance = 0
humanoid.Changed:connect(function()
if humanoid.Jump then
humanoid.Jump=false
end
end)

I have this in a LocalScript. It's supposed to disable the character jumping and lock them into First Person View, however it's very buggy online and sometimes won't work at all.

3 comments

0

is it in a local script? in startergui

0

You don't need that if then statement, and if your character is locked in FPS then you don't need to change the max zoom to 0

0

Localscript.

2 answers

✓ Accepted answer

I'v found a few glitches with the script and fixed them up for you. It now locks the person into LockFirstPerson and disables jumping. Have it in a LocalScript inside StarterPack.

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character ~= nil;
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid");

local LastJump = time();
Humanoid.Changed:connect(function()
game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
if Humanoid.Jump then
Humanoid.Jump = false;
end
end)

It's because you're too slow -__-. If you're checking if it's jumping then you're obviously too late to make it stop jumping.

local player = game.Players.LocalPlayer
if not player.Character then player.CharacterAdded:wait() end
humanoid = player.Character:WaitForChild("Humanoid")

player.CameraMode = "LockFirstPerson"
player.CameraMaxZoomDistance = 0
humanoid.Changed:connect(function()
humanoid.Jump = false
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.