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

Humanoid Jump Power resetting after death?

Asked by 2 years ago
Edited 2 years ago

Im trying to make a game where every second you jump power gets higher and higher and when the player dies it just resets the players jump power.At the start of the game you press a button to start the jump loop. Here is the 2 scripts. There is also a intvalue called jumpPower and a remote event called jump

server script in server script service

local Jump = game.ReplicatedStorage.Jump
local jumpPower = game.ReplicatedStorage.JumpPower


Jump.OnServerEvent:Connect(function(plr)
    print("event called")
    local char = plr.Character
    jumpPower.Value = 2
    local humanoid = char:FindFirstChild("Humanoid")
    function Jump()
         while wait(1) do
            jumpPower.Value += 1.5
            humanoid.JumpPower = jumpPower.Value
            wait(1)
            print(humanoid.JumpPower)
        end
    end

    Jump()

    plr.CharacterAdded:Connect(function(char)
        char:FindFirstChild("Humanoid").JumpPower = jumpPower.Value

    end)

end)

local script

local plr = game.Players.LocalPlayer

local Button = script.Parent.TextButton
local Label = script.Parent.TextLabel
local door = game.Workspace.Door
local debounce = false
local char = plr.Character
local jumpPower = 2
local jump = game.ReplicatedStorage.Jump


Label.Visible = false
door.CanCollide = true
door.Transparency = 0.2
Button.Visible = true


Button.MouseButton1Click:Connect(function()
    if debounce == false  then
        debounce = true
        Label.Visible = true
        for i = 5, 0, -1 do
            Label.Text = "Starting in "..i.." Seconds"
            wait(1)
        end
        Label.Visible = false
        door.CanCollide = false
        door.Transparency = 1
        Button.Visible = false
        jump:FireServer(plr)
    end

end)
0
Why is the server script same as the local script?? Voruel 41 — 2y
0
To start, the "CharacterAdded" event never gets reached. The Jump() function contains a while loop so until that while loop is exited or breaks -- code after that line will never run. PhantomVisual 992 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago

The reason why Its resetting the jump power Is because ROBLOX Is actually forcing the player to reset the jump power, Inside of the "StarterPlayer" folder, and check "Character Jump Setting" The player jump power will always be set to 50 each time the player respawn, so I would say, try to make a script that saves the current player jump power

0
How do I do that. I am so sorry but I am new to scripting and I dont know what to do willbillpill 5 — 2y
Ad

Answer this question