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

How can I stop jump power from stopping?

Asked by
yayachik1 -11
2 years ago

I have a server script inside of serverscriptservice that makes the person playing's jump power increase by 1 every 1 second as well as their speed (although that was set to 0 since we decided we didnt want it enabled rn) as well as some leaderstats. The script does as intended, however once a players jump power reaches 1000, it stops increasing. Does anyone know what the problem is and if its possible to fix it?

01function increaseStats(hum, speedVal, jumpVal)
02    spawn(function()
03        while wait(0.01) do
04            hum.JumpPower += 1
05            hum.WalkSpeed += 0
06 
07            speedVal.Value = hum.WalkSpeed
08            jumpVal.Value = hum.JumpPower
09        end
10    end)
11end
12 
13game.Players.PlayerAdded:Connect(function(plr)
14 
15    local totalWalkspeed
View all 48 lines...

1 answer

Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago

the limit for JumpPower is 1000, the only solution is to make a custom jump method, that is, when you press Space you give your character enough velocity so that he flies up according to his jump power.

create a LocalScript in StarterCharacterScripts, name is up to you.

01local UserInputService = game:GetService("UserInputService")
02 
03local character = script.Parent
04 
05local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
06local humanoid = character:WaitForChild("Humanoid")
07 
08local function onJumpRequest()
09    if humanoidRootPart and humanoid and humanoid.FloorMaterial then
10        humanoidRootPart.AssemblyLinearVelocity += Vector3.new(0, (humanoid:GetAttribute("JumpPower") or 0) / 4, 0)
11    end
12end
13 
14UserInputService.JumpRequest:Connect(onJumpRequest)

UserInputService.JumpRequest happens when you press Space or jump button on mobile, then it runs the onJumpRequest function which, if the player is on ground (if humanoid.FloorMaterial is not nil then he is standing on something meaning he is on ground) then i increase his AssemblyLinearVelocity by a custom JumpPower and divide it by 4 because AssemblyLinearVelocity adds more jump height than Humanoid.JumpPower, this is to simulate real JumpPower.

now for your other script.

01function increaseStats(hum, speedVal, jumpVal)
02    spawn(function()
03        while wait(0.01) do
04            hum:SetAttribute("JumpPower", hum:GetAttribute("JumpPower") + 1)
05            hum.WalkSpeed += 0
06 
07            speedVal.Value = hum.WalkSpeed
08            jumpVal.Value = hum:GetAttribute("JumpPower")
09        end
10    end)
11end
12 
13game.Players.PlayerAdded:Connect(function(plr)
14 
15    local totalWalkspeed
View all 51 lines...

instead of changing Humanoid.JumpPower, i create an attribute JumpPower, attributes are like custom properties, then all you do is change that one attribute, don't touch Humanoid.JumpPower.

https://developer.roblox.com/en-us/articles/instance-attributes

1
you may need to change `/ 4` to `/ 5` or other number if you need to precisely simulate JumpPower, i consider it a minor detail though if it's a sort of jumping simulator imKirda 4491 — 2y
1
actual legend thank you so much yayachik1 -11 — 2y
0
wow pro Xapelize 2658 — 2y
Ad

Answer this question