Advertisement
Descaii

Gui Point

Mar 4th, 2014
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.84 KB | None | 0 0
  1. Player = game.Players.LocalPlayer
  2. if Player:FindFirstChild("HasCar") then
  3.     CPos = Player.HasCar
  4. else
  5.     CPos = Instance.new("Vector3Value",Player)
  6. end
  7. CPos.Name = "HasCar"
  8. Char = Player.Character
  9. --Char.Torso.Anchored = true
  10. Mouse = Player:GetMouse()
  11. function Point(UD1,UD2)
  12.     local X=UD1.X.Offset-UD2.X.Offset
  13.     local Y=UD1.Y.Offset-UD2.Y.Offset
  14.     local Hyp=math.sqrt(X^2+Y^2)
  15.     local AS=math.atan2(Y,X)
  16.     return 360*(AS/(math.pi*2))
  17. end
  18. Velocity = Vector2.new(0,0)
  19. Rot = 0
  20. Size = 512
  21. Cop = 3
  22. Players = {}
  23. local UI=Instance.new("ScreenGui",Player.PlayerGui)
  24. UI.Name = "Car Moving"
  25. local F=Instance.new("ImageLabel",UI)
  26. F.ZIndex = 5
  27. F.Size=UDim2.new(0,50,0,30)
  28. F.Position=UDim2.new(0.5,-25,0.5,-15)
  29. F.BackgroundTransparency = 1
  30. F.Image = "http://www.roblox.com/asset/?id="..161150995-1 -- Car
  31. local Back = Instance.new("Frame",UI)
  32. Back.BackgroundTransparency = 0
  33. Back.BackgroundColor3 = Color3.new(0.5,0.5,0.5)
  34. Back.Size = UDim2.new(1,0,1,0)
  35. local Ground = Instance.new("Frame",UI)
  36. Ground.Size = UDim2.new(0,Size*Cop,0,Size*Cop)
  37. Ground.ZIndex = 2
  38. Ground.BackgroundTransparency = 1
  39. function NewPlayer(Pos)
  40.     local F=Instance.new("ImageLabel",UI)
  41.     F.ZIndex = 5
  42.     F.Size=UDim2.new(0,50,0,30)
  43.     F.Position=UDim2.new(0.5,-25,0.5,-15)
  44.     F.BackgroundTransparency = 1
  45.     F.Image = "http://www.roblox.com/asset/?id="..161150995-1 -- Car
  46.     local C = Instance.new("TextLabel",UI)
  47.     C.TextColor3 = Color3.new(1,1,1)
  48.     C.TextStrokeColor3 = Color3.new(0,0,0)
  49.     C.TextStrokeTransparency = 0.5
  50.     C.Text = tostring(Pos.Parent)
  51.     C.ZIndex = 6
  52.     C.Size = UDim2.new(0,C.TextBounds.X,0,C.TextBounds.Y)
  53.     C.BackgroundTransparency = 1
  54.     local D = {}
  55.     D.F = F
  56.     D.Pos = Pos
  57.     D.C = C
  58.     table.insert(Players,D)
  59. end
  60. function FindPlayer(Name)
  61.     local FoundName = nil
  62.     for i,v in pairs(Players) do
  63.         if v.Pos.Parent then
  64.             if v.Pos.Parent.Name == Name then
  65.                 FoundName = true
  66.             end
  67.         end
  68.     end
  69.     return FoundName
  70. end
  71. for x = 1,Cop do
  72.     for y = 1,Cop do
  73.         local wat = Instance.new("ImageLabel",Ground)
  74.         wat.Size = UDim2.new(0,Size,0,Size)
  75.         wat.Image = "http://www.roblox.com/asset/?id="..158465747-1 --Ground
  76.         wat.Position = UDim2.new(0,Size*(x-1),0,Size*(y-1))
  77.         wat.BackgroundTransparency = 1
  78.         wat.ZIndex = 3
  79.     end
  80. end
  81. local Control = Instance.new("TextLabel",UI)
  82. Control.Size = UDim2.new(0,500,0,20)
  83. Control.Text = "t = forward, g = backward, f = turn left, h = turn right"
  84. Control.TextColor3 = Color3.new(0,0,0)
  85. Control.BackgroundTransparency = 1
  86. Control.TextScaled = true
  87. Control.Position = UDim2.new(0.5,-250,0,0)
  88. Control.ZIndex = 10
  89. local B={}
  90. p1=F.Size.X.Offset/2
  91. p2=F.Size.Y.Offset/2
  92. LastAngle = 0
  93. Begin = Vector2.new(0,0)
  94. function GetDistance(P1,P2)
  95.     return math.sqrt((P1.X-P2.X)^2 + (P1.Y-P2.Y)^2)
  96. end
  97. game:GetService("RunService").RenderStepped:connect(function()
  98.     if Player:FindFirstChild("HasCar") and Player:findFirstChild("PlayerGui") then
  99.         CPos = Player.HasCar
  100.     else
  101.         CPos = Instance.new("Vector3Value",Player)
  102.     end
  103.     if not Player:FindFirstChild("PlayerGui") then
  104.         CPos:Remove()
  105.     end
  106.     CPos.Name = "HasCar"
  107.     F.Rotation=Rot--Point(UDim2.new(0,Begin.X,0,Begin.Y),UDim2.new(0,Mouse.X,0,Mouse.Y))
  108.     --F.Position=UDim2.new(0,Begin.X+math.cos(math.rad(F.Rotation))*-25,0,Begin.Y+math.sin(math.rad(F.Rotation))*-25)
  109.     Ground.Position = UDim2.new(0,Begin.X,0,Begin.Y)
  110.     local Dis = (math.abs(F.Rotation-LastAngle))
  111.     Begin = Begin +Velocity
  112.     CPos.Value = Vector3.new(Begin.X,Begin.Y,F.Rotation)
  113.     for i,v in pairs(B) do
  114.         if GetDistance(v.P.AbsolutePosition,v.Point) < 500 then
  115.             v.Position=v.Position+v.Velocity
  116.         else
  117.             v.P.Size = UDim2.new(0,50,0,50)
  118.             v.P.BackgroundColor3 = Color3.new(1,1,0)
  119.             v.P.BackgroundTransparency = 0.5
  120.             game:GetService("Debris"):AddItem(v.P,5)
  121.         end
  122.         v.P.Position = v.Position+UDim2.new(0,Begin.X,0,Begin.Y)
  123.     end
  124.     for i,v in pairs(game.Players:GetPlayers()) do
  125.         if v ~= Player then
  126.             if v:findFirstChild("HasCar") then
  127.                 if not FindPlayer(v.Name) then
  128.                     NewPlayer(v:findFirstChild("HasCar"))
  129.                     print("New Player: " ..v.Name,v:findFirstChild("HasCar").Value)
  130.                 end
  131.             end
  132.         end
  133.     end
  134.     for i,v in pairs(Players) do
  135.         v.F.Rotation = v.Pos.Value.Z+180
  136.         v.F.Position = UDim2.new(0.5,v.Pos.Value.X+Begin.X,0.5,v.Pos.Value.Y+Begin.Y)
  137.         v.C.Position = v.F.Position -UDim2.new(0,0,0,30)
  138.         v.C.Text = tostring(v.Pos.Parent)
  139.         v.C.Size = UDim2.new(0,v.C.TextBounds.X,0,v.C.TextBounds.Y)
  140.         if not v.Pos.Parent:IsA("Player") or not v.Pos.Parent:IsDescendantOf(game.Players) then
  141.             table.remove(Players,i)
  142.             v.F:Destroy()
  143.             v.C:Destroy()
  144.         end
  145.     end
  146.     --[[if (Dis > 5 and Dis < 350 and Velocity.magnitude > 5) then
  147.         print(math.abs(F.Rotation-LastAngle),Velocity.magnitude)
  148.         local TrailGui = Instance.new("Frame",UI)
  149.         TrailGui.BackgroundColor3 = Color3.new(0,0,0)
  150.         TrailGui.BackgroundTransparency = 0.5
  151.         TrailGui.Size = UDim2.new(0,5,0,5)
  152.         TrailGui.Position = F.Position+UDim2.new(0,p1,0,p2)
  153.         TrailGui.Rotation = F.Rotation
  154.         game:GetService("Debris"):AddItem(TrailGui,3)
  155.     end]]
  156.     LastAngle = F.Rotation
  157.     Velocity = Velocity*0.95
  158. end)
  159. --[[Mouse.Button1Down:connect(function()
  160.     local a={}
  161.     a.P = Instance.new("Frame",UI)
  162.     a.P.Rotation=F.Rotation
  163.     local b=(Vector2.new(math.cos(math.rad(F.Rotation)),math.sin(math.rad(F.Rotation))))--((F.AbsolutePosition+Vector2.new(p1,p2))-Vector2.new(0,5,0,5))-Vector2.new(Mouse.X,Mouse.Y)).unit
  164.     a.Velocity=-UDim2.new(0,b.X*20,0,b.Y*20)
  165.     a.P.Size=UDim2.new(0,10,0,10)
  166.     a.Position = F.Position+UDim2.new(0,p1,0,p2)
  167.     a.P.Position=a.Position+UDim2.new(0,Begin.X,0,Begin.Y)
  168.     a.Point = F.AbsolutePosition
  169.     table.insert(B,a)
  170. end)]]
  171. GD = false
  172. SD = false
  173. DD = false
  174. AD = false
  175. Mouse.KeyDown:connect(function(k)
  176.     if k == "t" then
  177.         GD = true
  178.         repeat wait()
  179.             Velocity = Velocity -Vector2.new(math.cos(math.rad(F.Rotation)),math.sin(math.rad(F.Rotation)))
  180.         until not GD
  181.     end
  182.     if k == "g" then
  183.         SD = true
  184.         repeat wait()
  185.             Velocity = Velocity +Vector2.new(math.cos(math.rad(F.Rotation)),math.sin(math.rad(F.Rotation)))
  186.         until not SD
  187.     end
  188.     if k == "h" then
  189.         DD = true
  190.         repeat wait()
  191.             if Rot > -1 then
  192.                 if Rot < 361 then
  193.                     Rot = Rot +0.5*Velocity.magnitude
  194.                 else
  195.                     Rot = 0
  196.                 end
  197.             else
  198.                 Rot = 360
  199.             end
  200.         until not DD
  201.     end
  202.     if k == "f" then
  203.         AD = true
  204.         repeat wait()
  205.             if Rot > -1 then
  206.                 if Rot < 361 then
  207.                     Rot = Rot -0.5*Velocity.magnitude
  208.                 else
  209.                     Rot = 0
  210.                 end
  211.             else
  212.                 Rot = 360
  213.             end
  214.         until not AD
  215.     end
  216. end)
  217. Mouse.KeyUp:connect(function(k)
  218.     if k == "t" then
  219.         GD = false
  220.     end
  221.     if k == "g" then
  222.         SD = false
  223.     end
  224.     if k == "h" then
  225.         DD = false
  226.     end
  227.     if k == "f" then
  228.         AD = false
  229.     end
  230. end)
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259. --[[
  260. function GetService(v)
  261.     if pcall(function() game:GetService(v) end) then
  262.         return game:GetService(v)
  263.     else
  264.         return nil
  265.     end
  266. end
  267. local tab = {}
  268. tab.__index = function(i,v)
  269.     return game:GetService(v) or _G[v]
  270. end
  271. setmetatable(_G,tab)
  272. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement