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

Multiplier is not a valid member of Folder???

when i test play on Roblox studio, the log says this : Multiplier is not a valid member of Folder Stack Begin Script 'ServerScriptService.Stats', Line 21 Stack End And also the multiplier value does not show up in leaderstats

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("Clidat")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = player
	leaderstats.Name = "leaderstats"
	
	local Clicks = Instance.new("IntValue", leaderstats)
	Clicks.Name = "Clicks"
	Clicks.Value = DataStore:GetAsync(player.UserId) or 0
	
	local mult = Instance.new("IntValue", leaderstats)
	mult.Name = "Multiplier"
	mult.Value = DataStore:GetAsync(player.UserId) or 1
end)

game.Players.PlayerRemoving:Connect(function(player)
	local Clicks = player.leaderstats.Clicks
	local mult = player.leaderstats.Multiplier
	local dattosa = {
	Clicks.Value
	mult.Value
	}
	DataStore:SetAsync(player.UserId, dattosa)
end)

1 answer

✓ Accepted answer

You need to add a comma to your dattosa table.

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("Clidat")

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

    local Clicks = Instance.new("IntValue", leaderstats)
    Clicks.Name = "Clicks"
    Clicks.Value = DataStore:GetAsync(player.UserId) or 0

    local mult = Instance.new("IntValue", leaderstats)
    mult.Name = "Multiplier"
    mult.Value = DataStore:GetAsync(player.UserId) or 1
end)

game.Players.PlayerRemoving:Connect(function(player)
    local Clicks = player.leaderstats.Clicks
    local mult = player.leaderstats.Multiplier
    local dattosa = {
    Clicks.Value,
    mult.Value
    }
    DataStore:SetAsync(player.UserId, dattosa)
end)


1 comment

0

oh and also multiplier wouldn't show up too

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