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

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

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by 2 years ago

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

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

0
I'm using single quotes starranger4 4 — 2y

Answer this question