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)

10 comments
How does Bag replicate itself into the Player?
on the datastore script it stores it there. its just for testing currently
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
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.
i added it under the other script
everything else works except for when i try to sell it, it returns as 0
show us where you add value to the bag, not your datastore
my bad one sec
there
you cant add value to leaderstats directly from a local script, use a remote event.