Script running but simply not doing what it says(no errors)

35 Views Asked by At

Im making a simulator type game where when you walk on to a certain part, you can sell your stuff. Ive made the code to take away your stuff, but no matter what i do, it just will not do anything. The code sets the stat to zero but it doesnt actually happen in game. The puzzling thing is that there is no errors in the output

local hitbox = game.Workspace.SellBuildingHitbox

hitbox.Touched:Connect(function(hit)
    
    local plrname = hit.Parent.Name

    if game.Players:FindFirstChild(plrname) then
        
        local plr = game.Players:FindFirstChild(plrname)
        
        plr.Stats.Stomach.Value = 0 
        
        
    end

end)

Thanks in advance!

1

There are 1 best solutions below

0
Winper On
  1. If the variable is in the TAB menu then Stats is supposed to be named leaderstats
  2. If the variable is a Gui then change the text in the gui