As the Question states I'm trying to get these scripts to work for other players then just one player that it linked to the other players, As for an example Player 1,2,3 etc... is able to purchase from the Shop, but here's the problem when Player 1 purchases he has 100 tickets when it goes down to 70 so does Player 2 and 3 tickets as well but they don't get any items since it's Player 1 items, But when Player 2 or 3 purchase an item there's don't go down it stays the same number as what Player 1 tickets are so this leads them to have infinite amount of items without having to worry about there tickets to go down. When Player 1 uses all there tickets Player 2 and 3 can't buy anymore. I'm wounding how can I fix that with these scripts. Also here's what I'm talking about so you can understand more better.
http://http://imgur.com/a/MFfea
So here's the Scripts and I know I asked this already but my question is off the front page and wasn't fully answered and I would like this to be fix since this feature is part of my game. and to try and make it more understandable... English is not my best Subject even though it's my first language... But anyways here's the scripts the first 2 are what controls the leaderboard the last one is the main SurfaceShop Gui whichs works non or less but mostly it's the leaderboard problem.
Between it shows no errors when I test the scripts...
Manage Leaderboard Script (ServerScriptService) (Script)
values = {{"Tickets",100}} game.Players.ChildAdded:connect(function(player) local leaderboard = Instance.new("Folder") leaderboard.Name = player.Name for i=1,#values do local value = Instance.new("IntValue") value.Name = values[i][1] value.Value = values[i][2] value.Parent = leaderboard end local local_leaderboard = leaderboard:clone() local_leaderboard.Name = "leaderstats" leaderboard.Parent = script.Parent.Players local_leaderboard.Parent = player SSS_Players = script.Parent.Players:getChildren() end) game.Players.ChildRemoved:connect(function(player) script.Parent.Players[player.Name]:Destroy() SSS_Players = script.Parent.Players:getChildren() end) game.ServerStorage.ValueCommitQueue.ChildAdded:connect(function(folder) wait() --Debounce new additions to value commit queue so that all children of said additions are actually acquired local playerFolder = script.Parent.Players:findFirstChild(folder.Name) if playerFolder then local folderValues = folder:getChildren() for i=1, #folderValues do local playerValue = playerFolder:findFirstChild(folderValues[i].Name) if playerValue then playerValue.Value = folderValues[i].Value end end end wait() folder:Destroy() end)
Request Leaderboard Change Script (ReplicatedStorage) (Script)
values = script:WaitForChild("RequestedValues"):getChildren() playerName = script.playerName queue = game.ServerStorage.ValueCommitQueue playerFolder = Instance.new("Folder") playerFolder.Name = playerName.Value playerFolder.Parent = queue --Move values to queue for i=1,#values do values[i].Parent = playerFolder end wait() script:Destroy()
Shop Script (StarterPack) (Local Script)
--Services-- local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") --Variables-- local Player = Players.LocalPlayer local PlayerGui = Player.PlayerGui local LeaderStats = Player:FindFirstChild("leaderstats") local RequestLeaderboardChangeMaster = game.ReplicatedStorage.RequestLeaderboardChange local Backpack = Player:FindFirstChild("Backpack") local StarterGear = Player:FindFirstChild("StarterGear") local SurfaceGui = ReplicatedStorage:FindFirstChild("Shop", true):Clone() SurfaceGui.Parent = PlayerGui local mouse = Player:GetMouse() local ItemsForSale = { ["Sword"] = { ["Cost"] = 10; ["Currency"] = "Tickets"; }, ["Sword2"] = { ["Cost"] = 20; ["Currency"] = "Tickets"; }, ["Sword3"] = { ["Cost"] = 30; ["Currency"] = "Tickets"; } } local ItemNames = {"Sword","Sword2","Sword3"} local function UpdateShopTarget() if mouse.Target then if mouse.Target.Name == "Shop 2" then SurfaceGui.Adornee = mouse.Target else SurfaceGui.Adornee = nil end else SurfaceGui.Adornee = nil end end local function GetMoney(Currency) local IntValue = LeaderStats:FindFirstChild(Currency) if IntValue then return IntValue.Value end return 0 end local function SubtractMoney(Currency, Amount) local LeaderboardChangeObject = RequestLeaderboardChangeMaster:clone() local valueToUpdate = Instance.new("IntValue") valueToUpdate.Name = Currency valueToUpdate.Value = GetMoney(Currency) - Amount valueToUpdate.Parent = LeaderboardChangeObject.RequestedValues LeaderboardChangeObject.playerName.Value = Player.Name LeaderboardChangeObject.Parent = game.Workspace end local function AwardItem(ItemName) local Item = ReplicatedStorage.Weapons:FindFirstChild(ItemName) if Item then Item = Item:Clone() Item.Parent = Backpack Item = Item:Clone() Item.Parent = StarterGear end end --SurfaceGui Pre-initialization-- local Window = SurfaceGui:FindFirstChild("Window") local ProtoButton = SurfaceGui:FindFirstChild("ProtoButton") for i=1, #ItemNames do newButton = ProtoButton:clone() newButton.Name = ItemNames[i] newButton.Position = UDim2.new(0,22,0,100*i) newButton.Active = true newButton.Visible = true newButton.Parent = Window end Window.CanvasSize = UDim2.new(1,0,0,100+100*#ItemNames) --SurfaceGui Variables-- local ArrayOfChildren = Window:GetChildren() for _, Button in pairs (ArrayOfChildren) do local ItemName = Button.Name --print("Got button", ItemName) local ItemAttributes = ItemsForSale[ItemName] if ItemAttributes ~= nil then --print("Got data for", ItemName) local Cost = ItemAttributes["Cost"] local Currency = ItemAttributes["Currency"] --print(" ", "Cost:", Cost) --print(" ", "Currency:", Currency) Button.Text = ItemName..": "..Cost.." "..Currency Button.MouseButton1Click:connect(function() if LeaderStats then if GetMoney(Currency) >= Cost then SubtractMoney(Currency, Cost) AwardItem(ItemName) end end end) end end mouse.Move:connect(UpdateShopTarget)