Hello there I have a problem with a touch it should take the backpack value and add it to the leaderstats Value and then comes the error in the console how do I fix that here is my script:
local toggle = 10
script.Parent.Parent.Touched:Connect(function(hit)
if toggle == 10 then
toggle = 0
local playern = hit.Parent.Name
local Player = game.Players:FindFirstChild(playern)
print("found")
local Save = Player.BackpackFill.Value
Player.leaderstats.Tea.Value = Save
Player.BackpackFill.Value = 0
wait(2)
toggle = 10
end
end)

4 comments
What? He's checking if an object with the name of whatever hit.Parent is is in Players,
There are many ways of finding a PLAYER from their character, and this is my way of finding a PLAYER.
But you're doing 2 checks, when just one is needed. See my example
As i said, this is MY way of finding a PLAYER, oh and also, changing the amount of checks (if's) just makes the script more accurate.