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

Jumping Sim Problem#1 Help i dont want my stats to reset when i die plus when i leave game!?

Asked by
Tizzel40 243 Moderation Voter
5 years ago
Edited 5 years ago

ok I am making a jumping sim game and so here are the values

game.Players.PlayerAdded:connect(function(plr)
    local stats = Instance.new("BoolValue",plr)
    stats.Name = "leaderstats"

    local cash = Instance.new("IntValue",stats)
    cash.Name = "JP"
    cash.Value = 0


    local cash = Instance.new("IntValue",stats)
    cash.Name = "JM"
    cash.Value = 0

    local cash = Instance.new("IntValue",stats)
    cash.Name = "JBux"
    cash.Value = 0

end)

now JP means Jump Points JM means Jump Movement And Jbux is a currency. Now Herse the others script.Basicly the "Main Script"

--JP Script (Local Script)
local play = game.Players.LocalPlayer
local Mouse = play:GetMouse()
local en = true
local jumpp = play.leaderstats.JP    

local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.J then
        if en == false then return end
        play.leaderstats.JP.Value = play.leaderstats.JP.Value + 1
        local Character = play.Character or play.CharacterAdded:wait()
local humanoid = Character:WaitForChild("Humanoid")
local anim = Instance.new("Animation", humanoid)

anim.AnimationId = "http://www.roblox.com/asset/?id=02115690198"

        local animTrack = humanoid:LoadAnimation(anim)
        animTrack:Play()
        --play.Character.Humanoid.WalkSpeed = 0
        --wait(1)
        --play.Character.Humanoid.WalkSpeed = 16
         en = false
        play.Character.Humanoid.JumpPower = play.Character.Humanoid.JumpPower + .200
        wait(.8)
        en = true
    --2113367266
    end

end)

above is the Jump Points Script. As you can see every time you press the "J" key your characters JP Value gose up by one and your jumppower gose up by ".200" and an animation will play. now be low is the "JM" the jump movement script

--Local Script for JM points.
local play = game.Players.LocalPlayer
local Mouse = play:GetMouse()
local en = true
local jumpp = play.leaderstats.JP    
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.M then
        if en == false  or play.leaderstats.JM.Value == 200 then return end  
        play.leaderstats.JM.Value = play.leaderstats.JM.Value + 1
        local Character = play.Character or play.CharacterAdded:wait()
local humanoid = Character:WaitForChild("Humanoid")
local anim = Instance.new("Animation", humanoid)

anim.AnimationId = "http://www.roblox.com/asset/?id=2115710353"

        local animTrack = humanoid:LoadAnimation(anim)
        animTrack:Play()
        --play.Character.Humanoid.WalkSpeed = 0
        --wait(1)
        --play.Character.Humanoid.WalkSpeed = 16
         en = false
        play.Character.Humanoid.WalkSpeed = play.Character.Humanoid.WalkSpeed + .250
        wait(1)
        en = true

    end

end)

Now in this script your points or "JM" (Jump Movement") can only go up to 200 and when you press "M" an animation will play And your walk Speed will increase by ".250"
now the thing with this is it works fine...Just until you die...

-your humanoid stats RESET!! And I don't want that to happen!!! is there any thing I need to change or add!? what can I do to make me spawn with the same "humanoid" stats!?! especially when you die. can I make it like "1 JP = = .200 Jump Power" I really don't know... can some one Please help me because I really want my jumping simulator game to work...

-T40

0
en means (Enabled) which is a little debounce to prevent spam. Tizzel40 243 — 5y

1 answer

Log in to vote
0
Answered by
INOOBE_YT 387 Moderation Voter
5 years ago

To fix the reset on respawn, you need to load the values into the humanoid each time they respawn. Use the .CharacterAdded event of the player so you can know when the character respawns and give the values back to the humanoid. To make it save when you leave and rejoin the game, you need to use datastores. There are a few good YouTube videos to watch which I recommend before the Wiki.

0
how do i exactly load them Tizzel40 243 — 5y
0
You change the properties of the Humanoid when they respawn to what the leaderboard says INOOBE_YT 387 — 5y
Ad

Answer this question