wait() local function get(parent,name) while (not parent:FindFirstChild(name)) do wait() end return parent[name] end; local plr = game.Players.LocalPlayer local screen = get(script.Parent,"ScreenGui") local workspace = get(screen,"Workspace") local menu = get(workspace,"Menu") local mouse = plr:GetMouse() local bird = get(workspace,"Bird") local paused,jump = false,false local hit = false local stats = { score = script.Score; best = script.Best; } local settings = { } function bird_physics() local grav = 20--14 local function collision() for _,v in pairs(workspace.Obstacles:GetChildren()) do local p1x,p1y,p2x,p2y = bird.AbsolutePosition.X,bird.AbsolutePosition.Y,v.AbsolutePosition.X,v.AbsolutePosition.Y local s1x,s1y,s2x,s2y = bird.AbsoluteSize.X,bird.AbsoluteSize.Y,v.AbsoluteSize.X,v.AbsoluteSize.Y if (((((p1y+s1y) >= p2y) and (p1y <= (p2y+s2y))) and (((p1x >= p2x) or ((p1x+s1x) >= p2x)) and (p1x <= (p2x+s2x)))) or ((bird.Position.Y.Offset > 460) or (bird.Position.Y.Offset < 0)) ) then bird:TweenPosition(bird.Position,"Out","Sine",0,true) game_over() end end end while wait() do if ((not paused) and (not jump) and (bird.Visible)) then bird:TweenPosition((bird.Position+UDim2.new(0,0,0,grav)),"Out","Sine",0.1,true) collision() end wait() end end function bird_jump() if (paused) then return end jump = true bird.Rotation = -50 bird:TweenPosition((bird.Position+UDim2.new(0,0,0,-90)),"Out","Sine",0.15,true) wait(0.25) bird.Rotation = -10 jump = false end function generate_obstacles() local obj = workspace.Obstacles.Obj:Clone(); workspace.Obstacles.Obj:Remove() local logs = {} local function same_ob(index) local yes = false for _,v in pairs(logs) do if (v == index) then yes = true end end return yes end delay(1,function() while wait() do if (not paused) then for _,v in pairs(workspace.Obstacles:GetChildren()) do v.Position = (v.Position+UDim2.new(0,-6,0,0)) --4 if ((v.Position.Y.Scale == 0) and (bird.AbsolutePosition.X > (v.AbsolutePosition.X+v.AbsoluteSize.X)) and (not same_ob(v.Name))) then stats.score.Value = (stats.score.Value+1) table.insert(logs,v.Name) end if (v.AbsolutePosition.X < 435) then v:Remove() end end end wait() end end) delay(3,function() while wait() do -- 140 space if (not paused) then local size1 = math.random(50,360) local size2 = ((500-size1)-140) local new1,new2 = obj:Clone(),obj:Clone() new1.Size,new1.Position = UDim2.new(0,25,0,size1),UDim2.new(1,10,0,0) new2.Size,new2.Position = UDim2.new(0,25,0,size2),UDim2.new(1,10,1,-size2) new1.Name,new2.Name = math.random(),math.random() new1.Parent,new2.Parent = workspace.Obstacles,workspace.Obstacles wait(2) end end end) end function game_over() hit,paused = true,true workspace.GameOver.Score.Text = stats.score.Value workspace.GameOver.Visible = true workspace.GameOver.Ok.MouseButton1Up:wait() bird.Position = UDim2.new(0.5,-20,0,200) workspace.GameOver.Visible,menu.Visible = false,true workspace.Obstacles:ClearAllChildren() stats.score.Value = 0 end function actions() local function update_stats() stats.best.Value = (stats.score.Value > stats.best.Value and stats.score.Value or stats.best.Value) workspace.Score.Current.Text = stats.score.Value workspace.Score.Best.Text = stats.best.Value end mouse.Button1Down:connect(function() bird_jump() end) menu.Play.MouseButton1Up:connect(function() menu.Visible = false paused = false end) menu.Changed:connect(function() bird.Visible,workspace.Obstacles.Visible = (not menu.Visible),(not menu.Visible) paused = menu.Visible end) stats.score.Changed:connect(update_stats) script.Ready.Value = true delay(2,update_stats) end while (not plr.Character) do wait() end; plr.Character:Remove() actions() generate_obstacles() bird_physics() Leaderstats.Score.Value = 0 if (not paused) then for _,v in pairs(workspace.Obstacles:GetChildren()) do v.Position = (v.Position+UDim2.new(0,-6,0,0)) --4 if ((v.Position.Y.Scale == 0) and (bird.AbsolutePosition.X > (v.AbsolutePosition.X+v.AbsoluteSize.X)) and (not same_ob(v.Name))) then Leaderstats.Score.value = Leaderstats.Score.Value + 1 table.insert(logs,v.Name) end if (v.AbsolutePosition.X < 435) then v:Remove() end end end
How would i make this in to a leaderboard of the best and there current score (This is for flappy bird) And the script is in startergui