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

[SOLVED] Why dosen't my LocalScript code run? (disable jump script)

Asked by 1 year ago
Edited 1 year ago

LocalScript

wait(2)
game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0

thats all. like this is simply to disable jumping, but somehow it dosent work, dosent error, but if i paste this line of code in the shell it works.

game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0

seems like it never runs.

3 answers

Log in to vote
0
Answered by 1 year ago

Create a normal script inside StarterPlayer > StarterCharacterScripts and paste this.

-- the reason why we put in StarterCharacterScripts is because it will only run if the player spawns/respawns

local character = script.Parent -- everything inside StarterCharacterScripts will be moved to the player's character when he/she joins the game, then the scripts will run. this one should get the character of the player when you join the game

local humanoid = character:FindFirstChildOfClass("Humanoid") -- FindFirstChildOfClass gets the child of an instance that is the same class as what is written in the argument which is "Humanoid"

humanoid.JumpPower = 0
humanoid.JumpHeight = 0
humanoid:SetSateEnabled(Enum.HumanoidStateType.Jumping, false) -- disables jumping

If you want explanations of the script, read the comments in the script.

Ad
Log in to vote
0
Answered by 1 year ago

You don't have to use a script for this, all you need to do is go to StarterPlayer and scroll down until you see CharacterUseJumpPower, then uncheck that

0
^ You'd also have to lower JumpHeight to 0 if you uncheck that, or JumpPower if it is checked. pwx 1581 — 1y
Log in to vote
0
Answered by 1 year ago

Some places local scripts just won't run, some places it will run in is:

A Player's Backpack, such as a child of a Tool A Player's character model A Player's PlayerGui A Player's PlayerScripts. The ReplicatedFirst service

More about local scripts: https://create.roblox.com/docs/reference/engine/classes/LocalScript

Answer this question