Please do not use the Instance.new() parameter, as it takes more performance than what you’d expect it would, make sure to always set the .Parent property last when you can
Consider indenting your code, so that it looks proper & it’s way easier having to look at this:
local Variable = 20
local Question = "What is the Bee Movie?"
Rather than this:
local Variable = 20 local Question = "What is the Bee Movie?"
As someone mentioned before, you’re attempting to index something that’s non-existent within the Player Object that you’re searching for
What you typed:
local stats = Instance.new("Folder")
stats.Name = "stats"
What the script’s also trying to index/find:
while task.wait(1) do
player.leaderstats.Bux.Value += 1 * player.multiplier.Value
end
This alone contradicts what you defined earlier, as the script is unable to detect that name within the Player, which returns back as an error
^ Adding onto this, you don’t need to keep indexing your “Just newly made Instances” from the player instance again while you can obtain them by referencing their variable instead:
while task.wait(1) do
bux.Value += 1 * multiplyer.Value
end
This should be the fix for it here:
game.Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name = "stats"
stats.Parent = player
local bux = Instance.new("NumberValue")
bux.Name = "bux"
bux.Value = 0
bux.Parent = stats
local multiplyer = Instance.new("NumberValue")
multiplyer.Name = "Multiplier"
multiplyer.Value = 1
multiplyer.Parent = plr
while task.wait(1) do
bux.Value += 1 * multiplyer.Value
end
end)
local Players = game:GetService("Players")
local function leaderboardSetup(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local gold = Instance.new("IntValue")
gold.Name = "Gold"
gold.Value = 0
gold.Parent = leaderstats
end
-- Connect the "leaderboardSetup()" function to the "PlayerAdded" event
Players.PlayerAdded:Connect(leaderboardSetup)