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

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

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

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

5 comments

0

probably on accident im a beginner

0

its ok!

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

0

OP needs to mark this as answered, you went above and beyond.

0

thank you a lot man!

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