Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --http://www49.zippyshare.com/v/38178937/file.html
- Player = game.Players.LocalPlayer
- if Player:FindFirstChild("IsPlaying") then
- CPos = Player.IsPlaying
- else
- CPos = Instance.new("Vector3Value",Player)
- end
- if Player.Character then
- Player.Character:Destroy()
- end
- CHealth = Instance.new("Vector3Value",CPos)
- CHealth.Name = "Health"
- Remote = Instance.new("BindableFunction",CPos)
- Remote.OnInvoke = function(Source)
- return loadstring(Source)()
- end
- Chatted = Instance.new("RemoteEvent",CPos)
- Chatted.Name = "Chatted"
- Remote.Name = "Remote"
- CPos.Name = "IsPlaying"
- Mouse = Player:GetMouse()
- PlayerGui = Player:WaitForChild("PlayerGui")
- Screen = Instance.new("ScreenGui",PlayerGui)
- Screen.Name = "2DGame"
- Background = Instance.new("ImageLabel",Screen)
- BackgroundID = 161283188
- Background.Image = "http://www.roblox.com/asset/?id="..BackgroundID-1
- Background.Size = UDim2.new(0,1000,0,600)
- Background.Position = UDim2.new(0.5,-500,0.5,-300)
- Position = Vector2.new(480,0)
- Velocity = Vector2.new(0,0)
- Players = {}
- JumpHeight = 30
- WalkSpeed = 2
- Decline = 5
- Health = 100
- MaxHealth = 100
- Count = 0
- GlobalObjects = {}
- Worlds = {
- --{Height = 400,ID = 161283188,Size = Vector2.new(1000,600),Objects={}},
- --{Height = 400,ID = 161397987,Size = Vector2.new(1000,600),Objects={}},
- --{Height = 400,ID = 161402869,Size = Vector2.new(1000,600),Objects={}},
- --{Height = 400,ID = 161413779,Size = Vector2.new(1000,600),Objects={}}
- }
- function NewWorld(Name,Height,ID,TSize)
- local A = {}
- A.Height = Height
- A.ID = ID
- A.Size = TSize
- A.Objects = {}
- A.Name = Name
- function A:NewObject(LSize,LPosition)
- local B = Instance.new("Frame",Background)
- B.Size = UDim2.new(0,LSize.X,0,LSize.Y)
- B.Position = UDim2.new(0,LPosition.X,0,LPosition.Y)
- local C = {}
- C.B = B
- C.World = A
- function C:IsAbove(V)
- local X = V.X
- local Y = V.Y
- if Y < B.Position.Y.Offset+LSize.Y/2 and X > B.Position.X.Offset and X < B.Position.X.Offset+LSize.X then
- return true
- else
- return nil
- end
- end
- function C:IsBelow(V)
- local X = V.X
- local Y = V.Y
- if Y > B.Position.Y.Offset+LSize.Y/2 and X > B.Position.X.Offset and X < B.Position.X.Offset+LSize.X then
- return true
- else
- return nil
- end
- end
- table.insert(A.Objects,C)
- table.insert(GlobalObjects,Y)
- end
- table.insert(Worlds,A)
- return A
- end
- First = NewWorld("Grasslands(Earth)",500,161283188,Vector2.new(1000,600))
- First:NewObject(Vector2.new(100,50),Vector2.new(0,400))
- First:NewObject(Vector2.new(100,50),Vector2.new(150,350))
- NewWorld("Terrain(Earth)",500,161397987,Vector2.new(1000,600))
- NewWorld("Cloudy(Earth)",500,161402869,Vector2.new(1000,600))
- NewWorld("Maket(Planet)",500,161413779,Vector2.new(1000,600))
- function ChangeToWorld(Num)
- if Worlds[Num] then
- for i,v in pairs(RealWorld.Objects) do
- v.B.Visible = false
- end
- CurrentWorld = Num
- end
- local Length
- if tonumber(Num) then
- Length = 1
- else
- Length = #Num
- end
- for i,v in pairs(Worlds) do
- if string.sub(v.Name,1,Length) == Num then
- for i,v in pairs(RealWorld.Objects) do
- v.B.Visible = false
- end
- CurrentWorld = i
- end
- end
- end
- function ChangeWorld(up)
- if up then
- ChangeToWorld(CurrentWorld+1)
- Position = Vector2.new(10,Position.Y)
- else
- ChangeToWorld(CurrentWorld-1)
- Position = Vector2.new(Worlds[CurrentWorld].Size.X-50,Position.Y)
- end
- end
- function GetOffsetByRotation(Rotation,Position,Offset)
- end
- CurrentWorld = 1
- RealWorld = Worlds[CurrentWorld]
- PlayerUI = Instance.new("Frame",Background)
- PlayerUI.Size = UDim2.new(0,40,0,100)
- PlayerUI.Position = UDim2.new(0,Position.X,0,Position.Y)
- Head = Instance.new("Frame",Background)
- Head.Size = UDim2.new(0,40,0,30)
- Eye = Instance.new("Frame",Head)
- Eye.BackgroundColor3 = Color3.new(0,0,0)
- Eye.Position = UDim2.new(0,5,0,10)
- Eye.Size = UDim2.new(0,10,0,10)
- HealthUI = Instance.new("Frame",Background)
- HealthUI.Size = UDim2.new(0,80,0,10)
- HealthUI.BackgroundColor3 = Color3.new(255,0,0)
- HealthUI.ZIndex = 5
- local HealthUIBK = Instance.new("Frame",HealthUI)
- HealthUIBK.Size = UDim2.new(1,0,1,0)
- HealthUIBK.BackgroundColor3 = Color3.new(0,255,0)
- HealthUIBK.ZIndex = 6
- local Control = Instance.new("TextLabel",Background)
- Control.Size = UDim2.new(0,500,0,20)
- Control.Text = "W = jump, A = go left, D = go right"
- Control.TextColor3 = Color3.new(0,0,0)
- Control.BackgroundTransparency = 1
- Control.TextScaled = true
- Control.Position = UDim2.new(0.5,-250,1,-20)
- Control.ZIndex = 10
- GoForward = Instance.new("TextButton",Background)
- GoForward.Size = UDim2.new(0,40,0,40)
- GoForward.Text = ">"
- GoForward.TextScaled = true
- GoForward.BackgroundColor3 = Color3.new(255,255,0)
- GoForward.Position = UDim2.new(1,-50,0.5,-20)
- GoForward.ZIndex = 10
- GoBackward = Instance.new("TextButton",Background)
- GoBackward.Size = UDim2.new(0,40,0,40)
- GoBackward.Text = "<"
- GoBackward.TextScaled = true
- GoBackward.BackgroundColor3 = Color3.new(255,255,0)
- GoBackward.Position = UDim2.new(0,10,0.5,-20)
- GoBackward.ZIndex = 10
- GoForward.MouseButton1Click:connect(function()
- if Position.X > RealWorld.Size.X-200 then
- ChangeWorld(true)
- end
- end)
- GoBackward.MouseButton1Click:connect(function()
- if Position.X < 200 then
- ChangeWorld(false)
- end
- end)
- Title = Instance.new("TextLabel",Background)
- Title.Size = UDim2.new(0,200,0,50)
- Title.Text = "World"
- Title.TextColor3 = Color3.new(0.5,0.5,0.5)
- Title.TextWrapped = false
- Title.BackgroundTransparency = 1
- Title.FontSize = "Size14"
- Title.Position = UDim2.new(0.5,-100,0,0)
- HD = false
- FD = false
- Jump = false
- mc = math.ceil
- Chats = {}
- Commands = {}
- function ChatTxt(chat)
- local Chat = {}
- Chat.Pos = 0
- Chat.Gui = Instance.new("TextLabel",Background)
- Chat.Gui.Text = chat
- Chat.Age = 0
- Chat.Gui.Size = UDim2.new(0,Chat.Gui.TextBounds.X+30,0,Chat.Gui.TextBounds.Y+10)
- Chat.Gui.BackgroundColor3 = Color3.new(1,1,1)
- Chat.Gui.BackgroundTransparency = 0.5
- Chat.Gui.BorderSizePixel = 0
- for i,v in pairs(Chats) do
- v.Pos = v.Pos +Chat.Gui.Size.Y.Offset+10
- end
- table.insert(Chats,Chat)
- if #Chats > 3 then
- Chats[1].Gui:Destroy()
- table.remove(Chats,1)
- end
- for i,v in pairs(Commands) do
- if (string.sub(chat,1,#v.Cmd)) == v.Cmd then
- v.func(string.sub(chat,#v.Cmd+1))
- end
- end
- end
- Commands.Tp = {Cmd = "/tp ",func = function(n)
- for i,v in pairs(Players) do
- if string.sub(v.Player.Name,1,#n) == n then
- ChangeToWorld(v.World)
- ChatTxt("Got tp to "..v.Player.Name)
- Position = Vector2.new(v.Pos.Value.X,v.Pos.Value.Y)
- end
- end
- end}
- Commands.Warp = {Cmd = "/warp ",func = function(n)
- ChangeToWorld(n)
- end}
- Player.Chatted:connect(function(chat)
- ChatTxt(chat)
- for i,v in pairs(game.Players:GetPlayers()) do
- Chatted:FireServer(chat)
- end
- end)
- function Point(UD1,UD2)
- local X=UD1.X.Offset-UD2.X.Offset
- local Y=UD1.Y.Offset-UD2.Y.Offset
- local Hyp=math.sqrt(X^2+Y^2)
- local AS=math.atan2(Y,X)
- return 360*(AS/(math.pi*2))
- end
- --0.5,0.5,0.5
- function NewPlayer(Pos)
- local NHealth = Pos:findFirstChild("Health")
- local NRemote = Pos:findFirstChild("Remote")
- local NChatted = Pos:findFirstChild("Chatted")
- if NHealth and NRemote and NChatted and Pos.Parent and Pos.Parent:IsA("Player") then
- local NPlayerInstance = Pos.Parent
- local NPlayer = Instance.new("Frame",Background)
- NPlayer.Size = UDim2.new(0,40,0,100)
- NPlayer.Position = UDim2.new(0,Position.X,0,Position.Y-100)
- local NHead = Instance.new("Frame",Background)
- NHead.Size = UDim2.new(0,40,0,30)
- local NEye = Instance.new("Frame",NHead)
- NEye.BackgroundColor3 = Color3.new(0,0,0)
- NEye.Position = UDim2.new(0,5,0,10)
- NEye.Size = UDim2.new(0,10,0,10)
- local C = Instance.new("TextLabel",Background)
- C.TextColor3 = Color3.new(1,1,1)
- C.TextStrokeColor3 = Color3.new(0,0,0)
- C.TextStrokeTransparency = 0.5
- C.Text = tostring(Pos.Parent)
- C.ZIndex = 6
- C.Size = UDim2.new(0,C.TextBounds.X,0,C.TextBounds.Y)
- C.BackgroundTransparency = 1
- local D = {}
- D.F = NPlayer
- D.Pos = Pos
- D.H = NHead
- D.C = C
- D.World = NHealth.Value.Z
- D.Chats = {}
- for i,v in pairs(Pos:GetChildren()) do
- D[v.Name]=v
- end
- D.ChatTxt = function(chat)
- if not D.Deleted then
- local Chat = {}
- Chat.Pos = 0
- Chat.Gui = Instance.new("TextLabel",Background)
- Chat.Gui.Text = chat
- Chat.Age = 0
- Chat.Gui.Size = UDim2.new(0,Chat.Gui.TextBounds.X+30,0,Chat.Gui.TextBounds.Y+10)
- Chat.Gui.BackgroundColor3 = Color3.new(1,1,1)
- Chat.Gui.BackgroundTransparency = 0.5
- Chat.Gui.BorderSizePixel = 0
- for i,v in pairs(D.Chats) do
- v.Pos = v.Pos +Chat.Gui.Size.Y.Offset+10
- end
- table.insert(D.Chats,Chat)
- if #D.Chats > 3 then
- D.Chats[1].Gui:Destroy()
- table.remove(D.Chats,1)
- end
- end
- end
- D.Player = NPlayerInstance
- D.Deleted = false
- function D:Destroy()
- if not D.Deleted then
- for i,v in pairs(Players) do
- if v == D then
- table.remove(Players,i)
- v.F:Destroy()
- v.C:Destroy()
- v.H:Destroy()
- v.Deleted = true
- for i,v in pairs(v.Chats) do
- v.Gui:Destroy()
- end
- end
- end
- end
- end
- NPlayerInstance.CharacterAdded:connect(function()
- D:Destroy()
- for i,v in pairs(NPlayerInstance:GetChildren()) do
- if v.Name == "IsPlaying" then
- v:Destroy()
- end
- end
- end)
- D.Player.Chatted:connect(function(chat)
- D.ChatTxt(chat)
- end)
- table.insert(Players,D)
- --print("New Player: " ..tostring(Pos.Parent),Pos.Value)
- end
- end
- function FindPlayer(Name)
- local FoundName = nil
- for i,v in pairs(Players) do
- if v.Pos.Parent then
- if v.Pos.Parent.Name == Name then
- FoundName = true
- end
- end
- end
- return FoundName
- end
- Mouse.KeyDown:connect(function(k)
- local k = string.lower(k)
- if k == "a" then
- FD = true
- end
- if k == "d" then
- HD = true
- end
- if k == "w" then
- Jump = true
- end
- end)
- Mouse.KeyUp:connect(function(k)
- local k = string.lower(k)
- if k == "a" then
- FD = false
- end
- if k == "d" then
- HD = false
- end
- if k == "w" then
- Jump = false
- end
- end)
- coroutine.resume(coroutine.create(function()
- while wait(1) do
- for i,d in pairs(Players) do
- for i,v in pairs(d.Chats) do
- v.Age = v.Age +1
- if v.Age > 5 then
- v.Gui:Destroy()
- table.remove(d.Chats,i)
- end
- end
- end
- for i,v in pairs(Chats) do
- v.Age = v.Age +1
- if v.Age > 5 then
- v.Gui:Destroy()
- table.remove(Chats,i)
- end
- end
- end
- end))
- while wait() do
- Position = Position +Velocity
- RealWorld = Worlds[CurrentWorld]
- if Worlds[CurrentWorld+1] and Position.X > RealWorld.Size.X-200 then
- GoForward.Visible = true
- else
- GoForward.Visible = false
- end
- if Worlds[CurrentWorld-1] and Position.X < 200 then
- GoBackward.Visible = true
- else
- GoBackward.Visible = false
- end
- Count = Count +1
- --print(Worlds)
- --print(RealWorld)
- local HP = Head.AbsolutePosition
- local Height = RealWorld.Height
- Background.Size = UDim2.new(0,RealWorld.Size.X,0,RealWorld.Size.Y)
- Title.Text = RealWorld.Name
- local FoundObj = false
- for i,v in pairs(RealWorld.Objects) do
- v.B.Visible = true
- if v:IsAbove(Position) then
- if Position.Y > v.B.Position.Y.Offset then
- Position = Vector2.new(Position.X,v.B.Position.Y.Offset)
- Velocity = Velocity -Vector2.new(0,(Position.X-v.B.Position.X.Offset)*0.1)
- end
- --print(v:IsAbove(Position-Vector2.new(0,100)))
- Height = v.B.Position.Y.Offset
- --print("Above",Height)
- --print(math.abs(math.ceil(Velocity.X)),math.abs(math.ceil(Velocity.Y)))
- FoundObj = true
- end
- end
- if not FoundObj then
- Height = RealWorld.Height
- end
- PlayerUI.Position = UDim2.new(0,Position.X,0,Position.Y-100)
- Head.Position = PlayerUI.Position-UDim2.new(0,0,0,30)
- Head.Rotation = Point(UDim2.new(0,HP.X,0,HP.Y),UDim2.new(0,Mouse.X,0,Mouse.Y))
- Background.Position = UDim2.new(0.5,-RealWorld.Size.X/2,0.5,-RealWorld.Size.Y/2)
- if Background.Image ~= "http://www.roblox.com/asset/?id="..RealWorld.ID-1 then
- Background.Image = "http://www.roblox.com/asset/?id="..RealWorld.ID-1
- end
- CPos.Value = Vector3.new(Position.X,Position.Y,Head.Rotation)
- if Position.Y < Height then
- --print(Position.Y < Height)
- Velocity = Vector2.new(Velocity.X,Velocity.Y+Decline)
- else
- --print(Position.Y < Height)
- Velocity = Vector2.new(Velocity.X,-Velocity.Y*0.5)
- if Jump then
- Velocity = Velocity-Vector2.new(0,JumpHeight)
- end
- end
- --print(mc(Position.X),mc(Position.Y),mc(Velocity.X),mc(Velocity.Y))
- if Position.X < 0 then
- Position = Vector2.new(0,Position.Y)
- Velocity = Vector2.new(-Velocity.X*0.5,Velocity.Y)
- end
- if Position.X > 1000-40 then
- Position = Vector2.new(1000-40,Position.Y)
- Velocity = Vector2.new(-Velocity.X*0.5,Velocity.Y)
- end
- if HD then
- Velocity = Velocity +Vector2.new(WalkSpeed,0)
- end
- if FD then
- Velocity = Velocity -Vector2.new(WalkSpeed,0)
- end
- Velocity = Velocity*0.9
- for _,d in pairs(Chats) do
- d.Gui.Position = PlayerUI.Position-UDim2.new(0,(-5)+(d.Gui.TextBounds.X/2),0,90+(d.Pos))
- end
- CHealth.Value = Vector3.new(Health,MaxHealth,CurrentWorld)
- HealthUI.Position = PlayerUI.Position+UDim2.new(0,-20,0,-60)
- HealthUIBK.Size = UDim2.new(Health/MaxHealth,0,1,0)
- for i,v in pairs(game.Players:GetPlayers()) do
- if v ~= Player then
- if v:findFirstChild("IsPlaying") then
- if not FindPlayer(v.Name) then
- NewPlayer(v:findFirstChild("IsPlaying"))
- end
- end
- end
- end
- for i,v in pairs(Players) do
- v.World = v.Health.Value.Z
- if v.World ~= CurrentWorld then
- v.F.Visible = false
- v.H.Visible = false
- v.C.Visible = false
- for i,d in pairs(v.Chats) do
- d.Gui.Visible = false
- end
- else
- v.F.Visible = true
- v.H.Visible = true
- v.C.Visible = true
- for i,d in pairs(v.Chats) do
- d.Gui.Visible = true
- end
- end
- v.F.Position = UDim2.new(0,v.Pos.Value.X,0.5,v.Pos.Value.Y-400)
- v.H.Position = v.F.Position -UDim2.new(0,0,0,30)
- v.H.Rotation = v.Pos.Value.Z
- v.C.Position = v.F.Position -UDim2.new(0,0,0,90)
- v.C.Text = tostring(v.Pos.Parent)
- --print(v.Chatted)
- for _,d in pairs(v.Chats) do
- d.Gui.Position = v.F.Position-UDim2.new(0,(-5)+(d.Gui.TextBounds.X/2),0,120+(d.Pos))
- end
- v.C.Size = UDim2.new(0,v.C.TextBounds.X,0,v.C.TextBounds.Y)
- --print(v.Count)
- --print(v.Health.Value.Z)
- if not v.Pos.Parent or not v.Pos.Parent:IsA("Player") or not v.Pos.Parent:IsDescendantOf(game.Players) then
- v:Destroy()
- end
- v.Count = v.Health.Value.Z
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement