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

ServerScriptService.Script:3: attempt to call field 'Name' (a string value) ?

Asked by 4 years ago

game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name("leaderstats") leaderstats.Parent = plr

local val = Instance.new("IntValue")
val.Name = "Points"
val.Value = 0
val.Parent = leaderstats

local val = Instance.new("IntValue")
val.Name = "Wins"
val.Value = 0
val.Parent = leaderstats

end)

its giving me the error in the title and i dont know how to fix it

1 answer

Log in to vote
1
Answered by
starmaq 1290 Moderation Voter
4 years ago
Edited 4 years ago
game.Players.PlayerAdded:Connect(function(plr) 
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats" 
    leaderstats.Parent = plr


    local val = Instance.new("IntValue")
    val.Name = "Points"
    val.Value = 0
    val.Parent = leaderstats

    local val = Instance.new("IntValue")
    val.Name = "Wins"
    val.Value = 0
    val.Parent = leaderstats
end)

Why were you doing this leaderstats.Name("leaderstats"), .Name is a property that you need to set to a string value, string values are a group of characters and words inside of these " "

"this is a string"
"pizza 25"
"cool"

Doing leaderstats.Name("leaderstats") doesn't make any sense, well it does, if .Name was a function, and "leaderstats" will act up like a paramater to it, but not in your caset, Name is a property, this the way of setting properties.

leaderstats.Name = "leaderstats"

Remember that = (this is called an operator) is used to set properties, or variables to something, something.function() and this format is always acting up like a function

0
probably on accident im a beginner Baboboss3000 0 — 4y
0
its ok! starmaq 1290 — 4y
0
Sorry admin, i didn't provide any explanation cause really there is no explanation for this, but I usually always explain any answer I do starmaq 1290 — 4y
0
OP needs to mark this as answered, you went above and beyond. BuDeep 214 — 4y
0
thank you a lot man! starmaq 1290 — 4y
Ad

Answer this question