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

How can I change a player's jump power by using a variable?

Asked by 2 years ago
Edited 2 years ago

local playerName = OykkoIsBack Players.(playerName).Character.Humanoid.JumpPower = 100 so I want to set my jump power to the variable that has the players name? im new to roblox scripting and this happened in my output Expected identifier, got '(' something similar to this happened i wrote this if game.Workspace.IntValue.Value = 0 then print("Value is 0") but i figured this out by adding a another = but this time i can't figure it out so i need someone to help me! really appreciate it if you could help me!

0
since this site is broken the code its not showing the spaces this is the code of the first script (the other ones are correct) local playerName = OykkoIsBack Players.(playerName).Character.Humanoid.JumpPower = 100 RasbaKolaLegend 0 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

Ok well, First we're going to save a text inside the variable "playerName", This text will be the player's name

local playerName = "OykkoIsBack"

Then we will build a path to the Players folder, obviously doing "game.Players" Then we're going to use the variable, since we aren't starting the line with the variable, we need to use [ ] so the variable works correctly, like this

local playerName = "OykkoIsBack"

game.Players[playerName]

Now we successfully have a path to the player, now we just go inside the character, humanoid and set their Jump Power to what we want

local playerName = "OykkoIsBack"

game.Players[playerName].Character.Humanoid.JumpPower = 100

Yet, I like setting both JumpPower and JumpHeight to 0, just in case, IDK why but yeah...

local playerName = "OykkoIsBack"

game.Players[playerName].Character.Humanoid.JumpPower = 100
game.Players[playerName].Character.Humanoid.JumpHeight = 100
Ad

Answer this question