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?
function increaseStats(hum, speedVal, jumpVal) spawn(function() while wait(0.01) do hum.JumpPower += 1 hum.WalkSpeed += 0 speedVal.Value = hum.WalkSpeed jumpVal.Value = hum.JumpPower end end) end game.Players.PlayerAdded:Connect(function(plr) local totalWalkspeed local totalJumpHeight local l = Instance.new("Folder") l.Name = "leaderstats" l.Parent = plr local jumpVal = Instance.new("NumberValue") jumpVal.Name = "Jump Power" jumpVal.Parent = l local speedVal = Instance.new("NumberValue") speedVal.Name = "Speed" speedVal.Parent = l plr.CharacterAdded:Connect(function(char) local hum = char:WaitForChild("Humanoid") if totalWalkspeed then print(totalWalkspeed .. ", " .. totalJumpHeight) hum.WalkSpeed, hum.JumpPower = totalWalkspeed, totalJumpHeight end increaseStats(hum, speedVal, jumpVal) hum.Died:Connect(function() totalWalkspeed = hum.WalkSpeed totalJumpHeight = hum.JumpPower end) end) end)
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.
local UserInputService = game:GetService("UserInputService") local character = script.Parent local humanoidRootPart = character:WaitForChild("HumanoidRootPart") local humanoid = character:WaitForChild("Humanoid") local function onJumpRequest() if humanoidRootPart and humanoid and humanoid.FloorMaterial then humanoidRootPart.AssemblyLinearVelocity += Vector3.new(0, (humanoid:GetAttribute("JumpPower") or 0) / 4, 0) end end UserInputService.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.
function increaseStats(hum, speedVal, jumpVal) spawn(function() while wait(0.01) do hum:SetAttribute("JumpPower", hum:GetAttribute("JumpPower") + 1) hum.WalkSpeed += 0 speedVal.Value = hum.WalkSpeed jumpVal.Value = hum:GetAttribute("JumpPower") end end) end game.Players.PlayerAdded:Connect(function(plr) local totalWalkspeed local totalJumpHeight local l = Instance.new("Folder") l.Name = "leaderstats" l.Parent = plr local jumpVal = Instance.new("NumberValue") jumpVal.Name = "Jump Power" jumpVal.Parent = l local speedVal = Instance.new("NumberValue") speedVal.Name = "Speed" speedVal.Parent = l plr.CharacterAdded:Connect(function(char) local hum = char:WaitForChild("Humanoid") if totalWalkspeed then -- totalJumpHeight can be `nil` you only check if totalWalkspeed exists! print(totalWalkspeed .. ", " .. totalJumpHeight) hum.WalkSpeed = totalWalkspeed end hum:SetAttribute("JumpPower", totalJumpHeight or 50) -- 50 is the default JumpPower you set as you like increaseStats(hum, speedVal, jumpVal) hum.Died:Connect(function() totalWalkspeed = hum.WalkSpeed totalJumpHeight = hum:GetAttribute("JumpPower") end) end) end)
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