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

Script no work leaderboard no work plz halp need help?

i made a script

local function onPlayerJoin(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = leaderstats
	leaderstats.Parent = player
	local credits = Instance.new ("IntValue")
	credits.name = "Credit(s)"
	credits.Value = "50"
	credits.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(onPlayerJoin)

and the output says " 16:51:50.409 - ServerScriptService.Script:3: bad argument #3 to 'Name' (string expected, got Object)" its a leadrboardscript

2 answers

✓ Accepted answer

ok so,

use game.Players.PlayerAdded:Connect(function(player) instead of local function onPlayerJoin(player)

game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder",player) -- this makes the folder leaderstats and puts it in the player
	stats.Name = "leaderstats"
	
	local credits = Instance.new("IntValue",stats) -- this makes the credits and puts it in the leaderstats
	credits.Name = "Credits(s)"
	credits.Value = 50
end)

2 comments

0

the only problem was the quotes

0

actually nvm this is better and shorter

local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats" --This is in quotes
    leaderstats.Parent = player
    local credits = Instance.new ("IntValue")
    credits.name = "Credit(s)"
    credits.Value = 50 --numbers are not in quotes
    credits.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(onPlayerJoin)

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