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