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

How do I fix the attempt to index number with 'Name' error in Roblox?

I don't know the answer to this solution, and here is my code, also I'm trying to just set a name of an IntValue inside a playerAdded function. Here is my code:

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new('Folder')
	leaderstats.Name = 'leaderstats'
	leaderstats.Parent = plr
	
	local Clicks = Instance.new('IntValue')
	Clicks.Value = 0
	Clicks.Name = 'clicks'
	Clicks.Parent = leaderstats
	
	local Rebirths = Instance.new('IntValue')
	Rebirths.Name = 'rebirths'
	Rebirths.Value = 1
	Rebirths.Parent = leaderstats
	
	local SuperRebirths = Instance.new("IntValue")
	SuperRebirths.Name = 'Super Rebirths'
	SuperRebirths.Value = 0
	SuperRebirths.Parent = leaderstats
	
	local PlayerData = Instance.new('Folder')
	PlayerData.Name = plr.Name
	PlayerData.Parent = game.ServerStorage.DataFolder
	
	local OneRebirthCost = Instance.new('IntValue')
	OneRebirthCost = 25
	OneRebirthCost.Name = 'OneRebirthCost'
	OneRebirthCost.Parent = game.ServerStorage.DataFolder:WaitForChild(plr.Name)

The place I'm trying to make an IntValue is here:

	local OneRebirthCost = Instance.new('IntValue')
	OneRebirthCost = 25
	OneRebirthCost.Name = 'OneRebirthCost'
	OneRebirthCost.Parent = game.ServerStorage.DataFolder:WaitForChild(plr.Name)

I haven't found any solutions yet.

Also all this code is in a Server Script inside ServerScriptService.

2 answers

✓ Accepted answer

I think it's just a typo. You forgot to add .Value to a line

OneRebirthCost = 25

Simply add .Value back like so

local OneRebirthCost = Instance.new('IntValue')
OneRebirthCost.Value = 25
OneRebirthCost.Name = 'OneRebirthCost'
OneRebirthCost.Parent = game.ServerStorage.DataFolder:WaitForChild(plr.Name)

are you using apostrophise '' instead of quotation marks ""? if you are try changing to quotation see if that works

1 comment

0

I'm using single quotes

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