Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Closed as Not Constructive by hiimgoodpack and maumaumaumaumaumua

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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)
Ad
Log in to vote
0
Answered by
4n3w 0
5 years ago

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