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

Script no work leaderboard no work plz halp need help?

Asked by 5 years ago

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

Log in to vote
0
Answered by
3wdo 198
5 years ago

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)
0
the only problem was the quotes Vortex_Vasne 89 — 5y
0
actually nvm this is better and shorter Vortex_Vasne 89 — 5y
Ad
Log in to vote
0
Answered by
nc2r 117
5 years ago
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)

Answer this question