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

Why is this number value returning 0?

Asked by 5 years ago
Edited 5 years ago
local db = true 
script.Parent.Touched:Connect(function(limb)
    if not db then
        return
    end
    db = false 
    --check for humanoid
    if limb.Parent.Humanoid then 
        print("Heart Found!")
        local plr = game:GetService("Players"):FindFirstChild(limb.Parent.Name)
        --if its a player
        if plr then 
            local coins = plr.leaderstats.Coins
            local bag = plr.otherStats.Bag
            local values = {coins.Value, bag.Value}
            print(values[1], values[2]) -- here it says bag value is 0, its not?
            if values[2] >= 1 then 
                coins.Value = values[1] + values[2]
                print(coins.Value)
            end
        end
    end




    wait(3) 
    db = true
end)

Whenever i step on the sell button it says the bag has 0 when the actual value has 3 or any number. Why is this?

How its stored?

local Tool = script.Parent;
local biteVal = 1
enabled = true


script.Parent.Activated:Connect(function()
    if not enabled  then
        return
    end

    enabled = false

    local plr = game.Players.LocalPlayer
    local bites = plr.leaderstats.Bites

    if plr.otherStats.Bag.Value < plr.otherStats["Bag Capacity"].Value then 

    Tool.GripForward = Vector3.new(-0.018, -0.307, -0.952)
    Tool.GripPos = Vector3.new(1.488, -0.36, -0.573)
    Tool.GripRight = Vector3.new(1, -0.02, -0.013)
    Tool.GripUp = Vector3.new(0.016, 0.952, -0.307)

    wait(.5)

    bites.Value = bites.Value + biteVal
    plr.otherStats.Bag.Value = plr.otherStats.Bag.Value + biteVal

    Tool.Handle.EatSound:Play()
    Tool.GripForward = Vector3.new(0, 0.167, -0.986)
    Tool.GripPos = Vector3.new(0.053, -0.099, 0.07)
    Tool.GripRight = Vector3.new(0.989, -0.149, -0.025)
    Tool.GripUp = Vector3.new(0.151, 0.975, 0.165)

    enabled = true
    else
        enabled = true 
end
end)

0
How does Bag replicate itself into the Player? NicholasY4815 55 — 5y
0
on the datastore script it stores it there. its just for testing currently sentry3 6 — 5y
0
i just changed it and its still returning that the value is 0 and it isnt? is it a bug or am i just stupid? i updated itabove too sentry3 6 — 5y
0
Do you mind showing how the data is retrieved and set onto the Bag value? I suspect that it might be an issue there - the code here seems fine. NicholasY4815 55 — 5y
View all comments (6 more)
0
i added it under the other script sentry3 6 — 5y
0
everything else works except for when i try to sell it, it returns as 0 sentry3 6 — 5y
0
show us where you add value to the bag, not your datastore DinozCreates 1070 — 5y
0
my bad one sec sentry3 6 — 5y
0
there sentry3 6 — 5y
0
you cant add value to leaderstats directly from a local script, use a remote event. DinozCreates 1070 — 5y

Answer this question