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

The hidden stat will not work and will not be added to the speed or coinage?

Asked by 4 years ago

So in my game that i'm trying to make, I have 2 folders set in the player. leaderstats and hiddenstats. hiddenstats is for the hidden stats that make the game work in the background (though they also aren't saving getting to that later) so in my speed pad the player's speed jumps to 30 but when I go to add to the hidden stat extraspeed, and walk again. It does not add the speed onto the player's speed as shown here:

local speedBoost = script.Parent
local mainSpeedValue = 30 -- how much the speed pad changes your speed to
local OriginalValue = 25 -- how much the normal player gets in the game

local function SteppedOn(part)
    local parent = part.Parent
    local data = game.Players:GetPlayerFromCharacter(parent)
    if game.Players:GetPlayerFromCharacter(parent) then
        parent.Humanoid.WalkSpeed = mainSpeedValue + data.hiddenstats.extraspeed.Value
        wait(5)
        parent.Humanoid.WalkSpeed = OriginalValue + data.hiddenstats.extraspeed.Value
    end
end

speedBoost.Touched:connect(SteppedOn)

The launching speed pad also does not work like in Speed Run 4:

debounce = true 
                       -- Debounce variable (so your function doesn't repeat itself)
function YourWalkspeedIsChanged(hit)    -- Function, with "hit" being the argument (or the object that touches your part)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true then -- Seeing if there's humanoid
        debounce = false                    -- "Locks" function, so it won't repeat
        hit.Parent.Humanoid.WalkSpeed = 25 + player.hiddenstats.extraspeed.Value  -- Changes the walkspeed
        debounce = true                 -- "Unlocks" function, so the function can run again
    end
end

script.Parent.Touched:connect(YourWalkspeedIsChanged)   -- Connection line, to run the function

My coin will also not work with the other hidden stat, extracoins in hiddenstats:

local db = true
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        if db == true then
            db = false
            script.Parent.Transparency = 1
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            local respawntime = script.Parent.RespawnTime.Value
            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 5 + player.hiddenstats.extracoins.Value -- change 'Coins' to your currency name.
            script.Sound:Play()
            wait(1)
            script.Parent.Transparency = 1
            wait(respawntime) -- time before respawn
            db = true
            script.Parent.Transparency = 0
        end
    end 
end)

I have no clue why these problems are occuring as it looks to be all connected properly and no errors related to these scripts are occuring in the output.

Credit to whoever I borrowed these codes from as some are from a video and scripting helpers question that I looked up for help.

Sorry if i asked too many questions at once, or it sounds like im begging. But my game will not work because these codes will not work.

Answer this question