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

it says 'Value is not a valid member of Folder' whenever I collect my coin, what do i do?

Can anyone tell me what I'm doing wrong because i copied exactly what

a youtuber showed on his video and it worked for him

local db = true
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		if db == true then
			db = false
			script.Parent.Transparency = 1
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			player.leaderstats.Coins.Value = player.leaderstats.Value +1
			script.Sound:Play()
			wait (1)
			script.Parent:Remove()
			
		end
	end
end)

i did the leaderboard correctly and this so im confused

2 answers

Well, you did everything correctly except line 08 player.leaderstats.Coins.Value = player.leaderstats.Value +1 first part was correct but second you missed out Coins Oh and one final thing, connect and Remove() are Deprecated meaning roblox will remove them anytime and might not be able to be used in the future. So instead of using them, use Connect and Destroy() instead! So the finished code would be:

local db = true
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        if db == true then
            db = false
            script.Parent.Transparency = 1
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.leaderstats.Coins.Value = player.leaderstats.Coins.Value +1
            script.Sound:Play()
            wait (1)
            script.Parent:Destroy()

        end
    end
end)

player.leaderstats.Coins.Value = player.leaderstats.Value +1 you forgot the coins in the other side so u have to do player.leaderstats.Coins.Value = player.leaderstats.Coins.Value+1

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