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

How do you prevent jumping?

Asked by
Zerio920 285 Moderation Voter
10 years ago
1local player = game.Players.LocalPlayer
2humanoid = player.Character:WaitForChild("Humanoid")
3player.CameraMode = "LockFirstPerson"
4player.CameraMaxZoomDistance = 0
5humanoid.Changed:connect(function()
6if humanoid.Jump then
7humanoid.Jump=false
8end
9end)

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.

0
is it in a local script? in startergui RM0d 305 — 10y
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 M39a9am3R 3210 — 10y
0
Localscript. Zerio920 285 — 10y

2 answers

Log in to vote
1
Answered by
DevWork 80
10 years ago

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.

01local Player = game.Players.LocalPlayer
02repeat wait() until Player.Character ~= nil;
03local Character = Player.Character
04local Humanoid = Character:WaitForChild("Humanoid");
05 
06local LastJump = time();
07Humanoid.Changed:connect(function()
08game:GetService('Players').LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
09if Humanoid.Jump then
10Humanoid.Jump = false;
11end
12end)
Ad
Log in to vote
0
Answered by
Lacryma 548 Moderation Voter
10 years ago

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.

1local player = game.Players.LocalPlayer
2if not player.Character then player.CharacterAdded:wait() end
3humanoid = player.Character:WaitForChild("Humanoid")
4 
5player.CameraMode = "LockFirstPerson"
6player.CameraMaxZoomDistance = 0
7humanoid.Changed:connect(function()
8humanoid.Jump = false
9end)

Answer this question