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

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

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)

2 comments

0

Make sure you spelled rebirth right and the capitalization right. Should it be Rebirth or rebirth?

0

idk

4 answers

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.

6 comments

0

wut

0

Just replace the word "rebirth" at line 5 for Value and see if it works

0

wait wut? wdym

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.

0

um ok, so change rebirth to value?

0

Yep

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)

3 comments

0

theres an infinite yield on line 6

0

pls help me

0

there try it

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!

2 comments

0

that screwed up my points for leaderstats

0

Then remove the upper function.. Please make sure you're spelling everything right, everything works on my end.

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 :)

2 comments

0

rebirth line 11 is wrong, and leaderstats line 2 is wrong, idk wut to do now...

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 :(

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