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

Why is rebirth not a valid member of folder on line 5?

Asked by 5 years ago
script.Parent.Touched:Connect(function(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    if human ~= nil then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr.leaderstats.rebirth.Value >= 10 then
            script.Parent.Transparency = .65
            script.Parent.CanCollide = false
            wait(.5)
            script.Parent.Transparency = 0 
            script.Parent.CanCollide = true
        end
    end
end)
0
Make sure you spelled rebirth right and the capitalization right. Should it be Rebirth or rebirth? NotedAPI 810 — 5y
0
idk xTheodxre 16 — 5y

4 answers

Log in to vote
0
Answered by 5 years ago

Is there another script making this NumberValue called "Rebirth" in the players?If Yes, you should check the script, if the script isnt changing the name of the NumberValue after putting it in the Player the NumberValue name will be "Value" so the game wont recognize it as "rebirth" but as "Value".

Try Changing the "rebirth" word at line 5 for "Value".If this works it means you gotta add a NumberValue.Name = "rebirth" to the other script- Or just leave it as it is, your choice.

0
wut xTheodxre 16 — 5y
0
Just replace the word "rebirth" at line 5 for Value and see if it works kevinsoaresv 47 — 5y
0
wait wut? wdym xTheodxre 16 — 5y
0
At the line 5 of your script theres a word called "rebirth", Check if it isnt spelled wrong or just replace it for the word "Value" and see if it works. kevinsoaresv 47 — 5y
View all comments (2 more)
0
um ok, so change rebirth to value? xTheodxre 16 — 5y
0
Yep kevinsoaresv 47 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

edited version of code (Fixed!)

    script.Parent.Touched:Connect(function(hit)
        local human = hit.Parent:FindFirstChild("Humanoid")
        if human ~= nil then
               local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        local leaderstats = plr:WaitForChild("leaderstats")
        local rebirth = plr:WaitForChild("Rebirths")
            if plr.leaderstats.rebirth.Value >= 10 then
                script.Parent.Transparency = .65
                script.Parent.CanCollide = false
                wait(.5)
                script.Parent.Transparency = 0
                script.Parent.CanCollide = true
            end
        end
    end)
0
theres an infinite yield on line 6 xTheodxre 16 — 5y
0
pls help me xTheodxre 16 — 5y
0
there try it FerbiZides 0 — 5y
Log in to vote
0
Answered by 5 years ago

Hey, so I believe what went wrong here is you trying to index a value that doesn't yet exist. Instead, we can use another function in the script that will activate once a player joins, and insert the Rebirths into the player. Here's the full code.

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new('IntValue', player)
    leaderstats.Name = 'leaderstats'
    local Rebirths = Instance.new("IntValue", leaderstats)
    Rebirths.Name = "Rebirths"
    Rebirths.Value = 10
end)
script.Parent.Touched:Connect(function(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    if human ~= nil then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr.leaderstats.Rebirths.Value >= 10 then
            script.Parent.Transparency = .65
            script.Parent.CanCollide = false
            wait(.5)
            script.Parent.Transparency = 0 
            script.Parent.CanCollide = true
        end
    end
end)

If this helped, be sure to accept my answer!

0
that screwed up my points for leaderstats xTheodxre 16 — 5y
0
Then remove the upper function.. Please make sure you're spelling everything right, everything works on my end. jensar141215 157 — 5y
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Hola. I'm going to do the best I can to help, but I don't think I can add anything more than what has already been brought to the table by other answers. So firstly, the error "'rebirth' is not a valid member of 'Folder' on line 5" essentially translates as "'rebirth' doesn't exist inside the folder" in casual English. This can either mean 1 of 2 things:

Possibility 1: 'rebirth' is Misspelled or Misnamed

Inside the "leaderstats" folder inside the player, there should already be an object called 'rebirth' according to your script. If you have renamed it in Studio, then the script will not work. Also, check for typos and capitalization just to be sure. If there is not an object titled 'rebirth' in the folder before the script is triggered, then it will throw this error in the console.

Possibility 2: 'rebirth' Doesn't Exist Yet

In this case, that means you haven't already created an object called 'rebirth' in the leaderstats folder. The script will throw this error in console because it is impossible to change something that does not exist. To do this, you would need to create the value "rebirth" before changing it. It would look something like this:

game.Players.PlayerAdded:Connect(function(plr)
    local rebirth = Instance.new("IntValue", plr.leaderstats); --// Creates "rebirth" in LS.
    rebirth.Name = "rebirth";
end)

script.Parent.Touched:Connect(function(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    if human ~= nil then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    local rebirth = plr.leaderstats:WaitForChild("rebirth");

        if rebirth.Value >= 10 then
            script.Parent.Transparency = .65
            script.Parent.CanCollide = false
            wait(.5)
            script.Parent.Transparency = 0 
            script.Parent.CanCollide = true
        end
    end
end)

I hope this helped. If neither of these solutions work, I am not sure what is wrong or how it could be fixed without seeing it myself. If you need any help, I will gladly help you in Team Create to fix your script if you desire. Best wishes :)

0
rebirth line 11 is wrong, and leaderstats line 2 is wrong, idk wut to do now... xTheodxre 16 — 5y
0
i can help you in team create if you want but that's about as much as I can do. sorry that i wasn't able to help :( Loughdough 291 — 5y

Answer this question