Backpack problem

So, I am doing a simulator game. After 7 spent hours I didn’t do anything.
Console is giving me errors whole time. I want to detect if player joins, is his backpack full?
I think the error is not needed for this. But here is the code (I spent some time to be a Member, I am 100% newbie and i don’t know how to get the code “font”)



local player = game.Players:GetFullName()
print(player)

print("1")

print("2")
wait(10)
if player.leaderstats.Coins.Value == script.Capacity.Value then
	print("3")
	repeat
		player.leaderstats.Coins.Value = -1
		print("4")
	until player.leaderstats.Coins.Value < script.Capacity.Value
else if player.leaderstats.Coins.Value > script.Capacity.Value then
		repeat
			player.leaderstats.Coins.Value = -1
			print("4")
		until player.leaderstats.Coins.Value < script.Capacity.Value
	end
end
backpackCapacity()

function backpackCapacity()
	print("2")
	wait(5)
	if player.leaderstats.Coins.Value == script.Capacity.Value then
		print("3")
		repeat
			player.leaderstats.Coins.Value = -1
			print("4")
		until player.leaderstats.Coins.Value < script.Capacity.Value
	end
	backpackCapacity()
end
backpackCapacity()

I made leaderstats folder inside every player, Coins, Money inside it.
UPDATE: error here:

17:34:42.899 Workspace.Backpack:8: attempt to index nil with ‘Coins’ - Server - Backpack:8
17:34:42.899 Stack Begin - Studio
17:34:42.899 Script ‘Workspace.Backpack’, Line 8 - Studio - Backpack:8
17:34:42.899 Stack End - Studio

Also, if is here someone REALLY good person, you can add me on discord: luky#7348
AND if you help on discord, and if you want more help to me, I can send small amount of Robux.
I appreciate every help or comment!

THANKS FOR EVERYTHING!

well to me it looks that the player is not an instance, rather a string so it is returning Coins.Value as nil because it simply does not exist
the player instance can be gotten (via a locoalscript) by using game.Players.LocalPlayer although there are many different ways to get it in a server script

1 Like

Okay, thanks for responding. But I don’t know exactly what do you mean. I think you mean to make the whole script localscript? I am newbie, sorry, also i can show you the whole game on discord. Thanks!

1 Like

I would recommend watching the Dev King’s scripting tutorials. He has like 25 of them, maybe do 2-3 a day so that you don’t get too bored, he really walks you through most things that you will need to know. It would be hard to list all of the errors in this script, to fix it you would probably have to alter most of the script. Learn more about scripting and come back to this once you know a little bit more. Also remember to take breaks, scripting can be quite frustrating and I find that getting a glass of water can really help. Here is a link to the Devking’s channel, you want his beginner series.

1 Like

Yes, thanks alot! I watched only Series “Noob to pro”, but CentiDev did for me all the work!

1 Like