Hello, I am making a menu for a game that I made. The script is very long, just find shop system, I want to make it so it control's it's leaderstats instead of nothing. So for example. GUI says 0 money Leaderstats say 100 money How could I possibly make it connect?
wait() local Player = game.Players.LocalPlayer local PlayerGui = Player.PlayerGui local Frame = script.Parent:WaitForChild("Main") local Gamepasses = script.Parent:WaitForChild("Gamepasses") local Shop = script.Parent:WaitForChild("Shop") local Side = script.Parent:WaitForChild("Side") local OpenGamepassShop = Side:WaitForChild("Gamepasses") local OpenMoneyShop = Side:WaitForChild("Shop") local TeamChangeButton = Side:WaitForChild("TeamChange") local SideStuff = script.Parent:WaitForChild("Side") local Menu = Frame:WaitForChild("Menu") local Logo = Menu:WaitForChild("Logo") local Intro = Frame:WaitForChild("Intro") local PapersPleaseLogo = Intro:WaitForChild("ImageLabel") local Play = Menu:WaitForChild("Play") local Teams = Menu:WaitForChild("Teams") local TeamGui = Menu:WaitForChild("Team") local Credits = Menu:WaitForChild("Credit") local Selection = Frame:WaitForChild("TeamSelect") local SelectedTeam = "Trainee" local Event = game:GetService("ReplicatedStorage"):WaitForChild("Main") local Groups = require(game:GetService("ReplicatedStorage"):WaitForChild("Groups")) local Template = script:WaitForChild("Template") local GamepassItems = game.ReplicatedStorage:WaitForChild("Gamepasses"):GetChildren() local MoneyItems = { {Amount=50,Price=20,Id = 47459935}, {Amount=200,Price=70,Id = 47460000}, {Amount=500,Price=150,Id = 47460085}, {Amount=1000,Price=200,Id = 47460115}, {Amount=10000,Price=500,Id = 47460155}, {Amount=20000,Price=700,Id = 47460180}, {Amount='Permit',Price=30,Id = 49889066}, } local ShopOpen = false local MoneyShopOpen = false local CreditsGui = Side:WaitForChild("Credits") local MoneyCredits = Player:WaitForChild("Money") local Pay if not Player:FindFirstChild("PayTime") then Pay = Instance.new("IntValue",Player) Pay.Name = "PayTime" Pay.Value = 300 else Pay = Player:FindFirstChild("PayTime") end local Passcode = "goteemg00d" --------------------------------------------------------------------------- --[[SHOP SYSTEM]]-- --CreditsGui.Text = "Money: $"..MoneyCredits.Value --MoneyCredits.Changed:connect(function() --CreditsGui.Text = "Money: $"..MoneyCredits.Value --end) for i,v in pairs(GamepassItems) do local cl = script:WaitForChild("ShopTemplate"):Clone() cl.Parent = Gamepasses cl.Position = UDim2.new(0,0,(i*0.06)-.06,0) cl.Text = v.Name cl.MouseButton1Down:connect(function() game:GetService("MarketplaceService"):PromptPurchase(game.Players.LocalPlayer,v.Value) end) end for i,v in pairs(MoneyItems) do local cl = script:WaitForChild("ShopTemplate"):Clone() cl.Parent = Shop cl.Position = UDim2.new(0,0,(i*0.06)-.06,0) cl.Text = "Buy $"..v.Amount.. " for "..v.Price.." robux" cl.MouseButton1Down:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer,v.Id) end) end OpenGamepassShop.MouseButton1Down:connect(function() if not ShopOpen then Gamepasses:TweenPosition(UDim2.new(.3,0,.2,0),"In","Sine",.5) wait(1) ShopOpen = true else Gamepasses:TweenPosition(UDim2.new(-.8,0,.2,0),"In","Sine",1) wait(1) ShopOpen = false end end) OpenMoneyShop.MouseButton1Down:connect(function() if not MoneyShopOpen then Shop:TweenPosition(UDim2.new(.3,0,.2,0),"In","Sine",.5) wait(1) MoneyShopOpen = true else Shop:TweenPosition(UDim2.new(-.8,0,.2,0),"In","Sine",1) wait(1) MoneyShopOpen = false end end) TeamChangeButton.MouseButton1Down:connect(function() if _G.DoneIntro then _G.DoneIntro = false Event:FireServer(Passcode,"Respawn") end end) spawn(function() while true do wait(1) if not Pay then return end if Pay.Value > 0 then Pay.Value = Pay.Value - 1 else Event:FireServer(Passcode,"AddCredits",100) Pay.Value = 300 end CreditsGui.Text = "Money: $"..MoneyCredits.Value.."\n Time until pay:\n"..Pay.Value.." seconds" end end) ------------------------------------------------------------------------------------------ --[[STOP REPEAT]]-- if _G.DoneIntro then wait() Frame:Destroy() Side.Visible = true CreditsGui.Visible = true Event:FireServer(Passcode,"Tools") wait() Event:FireServer(Passcode,"Spawn") Player.Chatted:connect(function(msg) if msg:sub(1,5) == "name/" then Event:FireServer(Passcode,"Name",msg:sub(6)) elseif msg:sub(1,7) == "donate/" then local msg = msg:sub(8) local Split = msg:find("/") if Split then local PlayerName = msg:sub(1,Split-1) local Amount = msg:sub(Split+1) if game.Players:FindFirstChild(PlayerName) and Amount then Event:FireServer(Passcode,"Donate",PlayerName,Amount) end end end end) return end --------------------------------------------------------------------------- --[[FUNCTIONS]]-- local function TweenProperty(Object,Property,Start,End,Interval) for i = Start,End,Interval do wait() Object[Property] = i end end --------------------------------------------------------------------------- --[[START UP]]-- PlayerGui:SetTopbarTransparency(0) Frame.Visible = true wait(1) Intro.Visible = true PapersPleaseLogo:TweenSizeAndPosition(UDim2.new(.4,0,.4,0),UDim2.new(.3,0,.3,0),"In","Sine",1) wait(1.5) PapersPleaseLogo:TweenSizeAndPosition(UDim2.new(.1,0,.1,0),UDim2.new(.45,0,-1,0),"Out","Sine",1) wait(2) Intro:Destroy() Menu.Visible = true Menu:TweenPosition(UDim2.new(0,0,0,0),"In","Sine",5) --wait(5.1) --spawn(function() -- while Frame.BackgroundTransparency == 0 do -- ypcall(function() -- wait(1.5) -- Logo:TweenPosition(UDim2.new(0.2,0,0.01,0),"In","Sine",1) -- wait(1.5) -- Logo:TweenPosition(UDim2.new(0.2,0,0.05,0),"In","Sine",1) -- end) -- end --end) ------------------------------------------------------------------------- --[[CREATE TEAMS]]-- local TotalTeams = #Groups for i,v in pairs(Groups) do local Clone = Template:Clone() Clone.Size = UDim2.new(1,0,1/TotalTeams,0) Clone.Position = UDim2.new(0,0,i*(1/TotalTeams) - 1/TotalTeams,0) Clone.Parent = Selection Clone.Name = v.Name Clone.Text = v.Name end ------------------------------------------------------------------------- --[[MENU SCREEN HANDLING]]-- Play.MouseEnter:connect(function() wait() Play.BackgroundTransparency = .6 end) Play.MouseLeave:connect(function() wait() Play.BackgroundTransparency = 1 end) Teams.MouseEnter:connect(function() wait() Teams.BackgroundTransparency = .6 end) Teams.MouseLeave:connect(function() wait() Teams.BackgroundTransparency = 1 end) Credits.MouseEnter:connect(function() wait() Credits.BackgroundTransparency = .6 end) Credits.MouseLeave:connect(function() wait() Credits.BackgroundTransparency = 1 end) Play.MouseButton1Down:connect(function() wait() _G.DoneIntro = true spawn(function() Event:FireServer(Passcode,"Team",SelectedTeam) end) end) Teams.MouseButton1Down:connect(function() wait() Menu.Visible = false Teams.BackgroundTransparency = 1 Selection.Position = UDim2.new(-1,0,0,0) Selection.Visible = true Selection:TweenPosition(UDim2.new(.15,0,0,0),"In","Sine",2) for i,v in pairs(Selection:GetChildren()) do v.MouseButton1Down:connect(function() for _,Info in pairs(Groups) do if Info.Name == v.Name then if Player:GetRankInGroup(Info.GroupId) >= Info.Rank then SelectedTeam = v.Name TeamGui.Text = "Team Chosen: "..SelectedTeam Selection:TweenPosition(UDim2.new(-1,0,0,0),"Out","Sine",2) wait(2) Menu.Visible = true Selection.Visible = false end end end end) end end)