Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

attempt to index nil with 'leaderstats'?

**I have tried to find what the error is but im new to studio and dont understand can someone please help me! **

script.Parent.Touched:Connect(function(hit)
	
	if hit then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player.leaderstats.Coin.Value >= script.Parent.Requirement.Value then
			player.leaderstats.Coin.Value -= script.Parent.Requirement.Value

			for i,v in pairs(workspace.Maps.DesertMap:GetChildren()) do
				v.Transparency = 1
				v.CanCollide = false
			end
		end
	end
end)

2 comments

0

I am trying to make a door that when you walk into it your money will be deducted from ur coins

0

What does attempt to index nil with mean

1 answer

✓ Accepted answer

I think the issue is you have to create a leaderstats folder before trying to call it. It does not automatically get inserted into the player, so you have to make it yourself. Try searching for how to make a leaderboard if you don't know how.

1 comment

0

Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.