Hello! I am having this issue where my script wont change JumpPower (even with it being JumpPower)
This is my script below (there are multiple debugging prints)
local player = game.Players.LocalPlayer
local Character = player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local MarketplaceService = game:GetService("MarketplaceService")
local JumpPower = Humanoid.JumpPower
local PlayerID = player.UserId
local BadgeID = 114472498
local Rep = game:GetService("ReplicatedStorage")
local CurPower = player.PlayerGui.CurPower.TextLabel
local PremOwned = false
local GPOwned = false
print("On Join: "..player.Name, JumpPower, PlayerID)
if player.MembershipType == Enum.MembershipType.Premium then
PremOwned = true
elseif MarketplaceService:UserOwnsGamePassAsync(PlayerID, BadgeID) then
GPOwned = true
else
local PremOwned = false
local GPOwned = false
end
Rep.IntroEvent.OnClientEvent:Connect(function()
JumpPower = 0
print("On Intro: "..player.Name, JumpPower, PlayerID)
wait(7)
while true do
print(PremOwned,GPOwned)
Humanoid.UseJumpPower = true
if PremOwned or GPOwned == true then
if PremOwned and GPOwned == true then --Both
JumpPower = JumpPower + 4
else -- Just 1
JumpPower = JumpPower + 2
end
else -- None
JumpPower = JumpPower + 1
end
CurPower.Text = "Power: "..JumpPower
wait(1)
end
end)
Everything works as intended and the power gets updated by my character isnt changing the jump height/power
You are attempting to change the jumppower on a local script, which will not work. Try using RemoteEvents which use server scripts to change the jump power. (I can show you how if you need)
local player = game.Players.LocalPlayer
local Character = player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local MarketplaceService = game:GetService("MarketplaceService")
local JumpPower = Humanoid.JumpPower
local PlayerID = player.UserId
local BadgeID = 114472498
local Rep = game:GetService("ReplicatedStorage")
local CurPower = player.PlayerGui.CurPower.TextLabel
local PremOwned = false
local GPOwned = false
print("On Join: "..player.Name, JumpPower, PlayerID)
if player.MembershipType == Enum.MembershipType.Premium then
PremOwned = true
elseif MarketplaceService:UserOwnsGamePassAsync(PlayerID, BadgeID) then
GPOwned = true
else
local PremOwned = false
local GPOwned = false
end
local SetJump = game.ReplicatedStorage.JumpEvent1
local AddJump = game.ReplicatedStorage.JumpEvent2
Rep.IntroEvent.OnClientEvent:Connect(function()
SetJump:FireServer(0)
print("On Intro: "..player.Name, JumpPower, PlayerID)
wait(7)
while true do
print(PremOwned,GPOwned)
Humanoid.UseJumpPower = true
if PremOwned or GPOwned == true then
if PremOwned and GPOwned == true then --Both
AddJump:FireServer(4)
else -- Just 1
AddJump:FireServer(2)
end
else -- None
AddJump:FireServer(1)
end
CurPower.Text = "Power: "..JumpPower
wait(1)
end
end)
Now make 2 RemoteEvents in Replicated Storage named JumpEvent1 and JumpEvent2
Make a script in ServerScriptService:
game.ReplicatedStorage.JumpEvent1.OnServerEvent:Connect(function(plr, power)
plr.Character.JumpPower = power
end)
game.ReplicatedStorage.JumpEvent2.OnServerEvent:Connect(function(plr, power)
plr.Character.JumpPower += power
end)
Exploiters only can inject local scripts so probably you still can change jump power in local script but just in a different way like Humanoid.JumpPower = Humanoid.JumpPower + 1
Let’s be clear that the character humanoid properties ARE modifiable by the client. The client can change the properties and the effects WILL occur. The server won’t be able to see these modifications though, but the script injections will work. So if your game’s mechanics heavily relies on JumpPower, I would have some sanity checks and anti-cheat checks on your server.
RIGHT NOW, this script is a local script, which means the humanoid properties are being edited on the client. I would HIGHLY advise that you make humanoid modifications on the SERVER rather than the client. If you would like a tutorial on how to do that, please shoot me a message and I’d be happy to go over that with you.
For the purpose of this code, let’s ignore that and get into the juice of the code!!
The reason why this code isn’t functioning correctly is because of your 5th line
Here, “JumpPower” a variable that is NOT storing the property of humanoid, but instead, it’s storing the INTEGER of the jump power. In other words, this variable is just a number. What we want to do is modify the humanoid’s property directly. Thus, at the bottom, you need to adjust all statements beginning with “JumpPower =” to “Humanoid.JumpPower =”.
Rep.IntroEvent.OnClientEvent:Connect(function()
JumpPower = 0
print("On Intro: "..player.Name, JumpPower, PlayerID)
wait(7)
while true do
print(PremOwned,GPOwned)
Humanoid.UseJumpPower = true
if PremOwned or GPOwned == true then
if PremOwned and GPOwned == true then --Both
Humanoid.JumpPower = JumpPower + 4
else -- Just 1
Humanoid.JumpPower = JumpPower + 2
end
else -- None
Humanoid.JumpPower = JumpPower + 1
end
CurPower.Text = "Power: "..JumpPower
wait(1)
end
end)
If an issue still persists, just comment on this post and I’ll check back
Ahh that makes sense too. But I have a question. Lets say your server jumppower was 3 and your local jumppower was 20, how would that even work? If you jumped onto a platform that 20 could reach but 3 couldn’t, what would it even look like on client vs. server?
The server would see it as a jump power of 3, whereas the client will see 20. All changes made on the server is visible to the client(s), but all changes made on the client will NOT be visible to the server. So, if the client changes his/her JumpPower from 3 to 20, they will be able to jump at a 20, even though the server sees 3. Jumping is a client movement (registered by UserJumpRequest), had it been registered on the server the client will receive a slight delay between jump button press and actual jump movement. So, the client has full control of that movement, and it is the servers job to verify that movement. I hope that clears any confusion!