Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- repeat wait() until game:GetService("Players").LocalPlayer.Character ~= nil
- game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.Anchored = true
- game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
- game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
- game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)
- game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.SelfView, false)
- local InputService = game:GetService("UserInputService")
- local TouchService = game:GetService("TouchInputService")
- local RS = game:GetService("ReplicatedStorage")
- local RunService = game:GetService("RunService")
- local TweenService = game:GetService("TweenService")
- local GUI = script.Parent:FindFirstChild("Game")
- local updatescore = RS.updatescore
- local Pipes = GUI.Pipes
- local Bird = GUI.Bird
- local birdhome = Bird.Position
- local assets = GUI.assets
- local PlayButton = GUI.playbutton
- local Score = GUI.score
- local BG1 = GUI.bg1
- local BG1Image = GUI.bg1.Image
- local BG2 = GUI.bg2
- local BG2Image = GUI.bg2.Image
- local tweeninfo = TweenInfo.new(10,Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
- local bg1tween = TweenService:Create(BG1, tweeninfo, {Position = UDim2.new(-1,0,0,0)})
- local bg2tween = TweenService:Create(BG2, tweeninfo, {Position = UDim2.new(0,0,0,0)})
- local scoreval = 0
- local scored = false
- local playing = false
- local velocity = 0
- local pipespeed = 4 -- lower == faster
- local function physics()
- if velocity < 1 then
- velocity = velocity + 0.002
- end
- end
- function touching(a,b)
- local ap = Vector2.new(a.Position.X.Scale, a.Position.Y.Scale)
- local as = Vector2.new(a.Size.X.Scale, a.Size.Y.Scale)
- local bp = Vector2.new(b.Position.X.Scale, b.Position.Y.Scale)
- local bs = Vector2.new(b.Size.X.Scale, b.Size.Y.Scale)
- local c = (ap.x + as.x > bp.x) and (bp.x + bs.x > ap.x) and (ap.y + as.y > bp.y) and (bp.y + bs.y > ap.y)
- if c then
- return true
- else
- return false
- end
- end
- local function updateBirdPos()
- Bird.Position = UDim2.new(0.166,0,Bird.Position.Y.Scale + velocity,0)--falling
- velocity = velocity * 0.9
- Bird.Rotation = velocity*450
- end
- local pipe = Pipes:GetChildren()
- local function collision()
- if playing then
- --wall
- for i = 1, #pipe do
- if pipe[i]:IsA("ImageLabel") then
- if touching(pipe[i],Bird) then
- playing = false
- bg1tween:Cancel()
- bg2tween:Cancel()
- BG1.Position = UDim2.new(0,0,0,0)
- BG2.Position = UDim2.new(1,0,0,0)
- end
- end
- end
- --point
- for i = 1, #pipe do
- if pipe[i]:IsA("Frame") and not scored then
- if touching(pipe[i],Bird) then
- print("potato")
- scored = true
- spawn(function()
- delay(1.5,function()
- scored = false
- end)
- end)
- scoreval = scoreval + 1
- Score.Text = "".. scoreval .." 社会信用!"
- if scoreval >= game:GetService("Players").LocalPlayer:WaitForChild("leaderstats")["顶级社会信用"].Value then
- updatescore:FireServer(scoreval)
- end
- --updatescore:FireServer(scoreval)
- end
- end
- end
- end
- end
- local function clearMap()
- for _, v in pairs(pipe)do
- if v.Name == "pipe" or v.Name == "point" then
- v.Visible = false
- v:Remove()
- end
- end
- end
- local function createpoint()
- local frame = Instance.new("Frame")
- frame.Name = "point"
- frame.BackgroundTransparency = 1
- frame.Size = UDim2.new(0.076,0,1,0)
- frame.Position = UDim2.new(1,0,0,0)
- frame.Parent = Pipes
- return frame
- end
- local function createSound(id, volume, looped, playonremove)
- local Sound = Instance.new("Sound")
- Sound.Looped = looped
- Sound.SoundId = id
- Sound.Volume = volume
- Sound.PlayOnRemove = playonremove
- return Sound
- end
- local function generatepipes()
- if playing then
- local random = math.random(10,60)/100
- local point = createpoint()
- local top = assets.pipe:Clone()
- top.Parent = Pipes
- top.Position = UDim2.new(1,0,0,0)
- top.Size = UDim2.new(0.076,0,random,0)
- local bottom = assets.pipe:Clone()
- bottom.Parent = Pipes
- bottom.Size = UDim2.new(0.076,0,(0.9-top.Size.Y.Scale)-.4,0)
- local bottommath = 1-bottom.Size.Y.Scale
- bottom.Position = UDim2.new(1,0,bottommath,0)
- local tweeninfo = TweenInfo.new(pipespeed,Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
- local toptween = TweenService:Create(top, tweeninfo, {Position = UDim2.new(-0.1,0,0,0)})
- local pointtween = TweenService:Create(point, tweeninfo, {Position = UDim2.new(-0.1,0,0,0)})
- local bottomtween = TweenService:Create(bottom, tweeninfo, {Position = UDim2.new(-0.1,0,bottommath,0)})
- pipe = Pipes:GetChildren()
- toptween:play()
- pointtween:play()
- bottomtween:play()
- delay(pipespeed, function()
- top:Remove()
- top = nil
- bottom:Remove()
- bottom = nil
- end)
- end
- end
- spawn(function()
- while task.wait(2) do
- generatepipes()
- end
- end)
- local function gravity()
- if playing then
- physics()
- updateBirdPos()
- collision()
- else
- Bird.Position = birdhome
- Bird.Rotation = 0
- PlayButton.Visible = true
- end
- end
- InputService.InputBegan:connect(function(input)
- if input.KeyCode == Enum.KeyCode.Space then
- print("gaben")
- velocity = velocity - 0.065
- if not playing then
- PlayButton.Visible = false
- scoreval = 0
- Score.Text = "0 社会信用!"
- playing = true
- bg1tween:play()
- bg2tween:play()
- delay(20,function()
- bg1tween:play()
- bg2tween:play()
- end)
- end
- end
- end)
- if InputService.TouchEnabled then
- InputService.TouchTap:connect(function(input)
- print("gaben")
- velocity = velocity - 0.065
- if not playing then
- PlayButton.Visible = false
- scoreval = 0
- Score.Text = "0 社会信用!"
- playing = true
- bg1tween:play()
- bg2tween:play()
- delay(20,function()
- bg1tween:play()
- bg2tween:play()
- end)
- end
- end)
- end
- PlayButton.MouseButton1Click:connect(function()
- local obunga = createSound("rbxassetid://3061644602",0.5,false)
- obunga.Parent = GUI
- obunga:Play()
- end)
- local bgpoop = 1
- RunService.Heartbeat:connect(function()
- pipe = Pipes:GetChildren()
- gravity()
- if BG1.Position == UDim2.new(-1,0,0,0) and bgpoop == 1 then
- bgpoop = 2
- BG1.Image = BG2Image
- BG2.Image = BG1Image
- BG1.Position = UDim2.new(0,0,0,0)
- BG2.Position = UDim2.new(1,0,0,0)
- bg1tween:play()
- bg2tween:play()
- elseif BG1.Position == UDim2.new(-1,0,0,0) and bgpoop == 2 then
- bgpoop = 1
- BG1.Image = BG1Image
- BG2.Image = BG2Image
- BG1.Position = UDim2.new(0,0,0,0)
- BG2.Position = UDim2.new(1,0,0,0)
- bg1tween:play()
- bg2tween:play()
- end
- if not playing then
- clearMap()
- velocity = 0
- end
- end)
- local randomsounds = {"rbxassetid://2619237842","rbxassetid://5235532522","rbxassetid://1372387751","rbxassetid://3442983711","rbxassetid://6622083025"}
- spawn(function()
- while task.wait(math.random(20,30)) do
- local rs = createSound(randomsounds[math.random(1,#randomsounds)],1,false)
- rs.Parent = GUI
- rs:Play()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement