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
9 years ago
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.

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

2 answers

Log in to vote
1
Answered by
DevWork 80
9 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.

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)
Ad
Log in to vote
0
Answered by
Lacryma 548 Moderation Voter
9 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.

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)

Answer this question