Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Player = game.Players.LocalPlayer
- if Player:FindFirstChild("HasCar") then
- CPos = Player.HasCar
- else
- CPos = Instance.new("Vector3Value",Player)
- end
- CPos.Name = "HasCar"
- Char = Player.Character
- --Char.Torso.Anchored = true
- Mouse = Player:GetMouse()
- 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
- Velocity = Vector2.new(0,0)
- Rot = 0
- Size = 512
- Cop = 3
- Players = {}
- local UI=Instance.new("ScreenGui",Player.PlayerGui)
- UI.Name = "Car Moving"
- local F=Instance.new("ImageLabel",UI)
- F.ZIndex = 5
- F.Size=UDim2.new(0,50,0,30)
- F.Position=UDim2.new(0.5,-25,0.5,-15)
- F.BackgroundTransparency = 1
- F.Image = "http://www.roblox.com/asset/?id="..161150995-1 -- Car
- local Back = Instance.new("Frame",UI)
- Back.BackgroundTransparency = 0
- Back.BackgroundColor3 = Color3.new(0.5,0.5,0.5)
- Back.Size = UDim2.new(1,0,1,0)
- local Ground = Instance.new("Frame",UI)
- Ground.Size = UDim2.new(0,Size*Cop,0,Size*Cop)
- Ground.ZIndex = 2
- Ground.BackgroundTransparency = 1
- function NewPlayer(Pos)
- local F=Instance.new("ImageLabel",UI)
- F.ZIndex = 5
- F.Size=UDim2.new(0,50,0,30)
- F.Position=UDim2.new(0.5,-25,0.5,-15)
- F.BackgroundTransparency = 1
- F.Image = "http://www.roblox.com/asset/?id="..161150995-1 -- Car
- local C = Instance.new("TextLabel",UI)
- 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 = F
- D.Pos = Pos
- D.C = C
- table.insert(Players,D)
- 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
- for x = 1,Cop do
- for y = 1,Cop do
- local wat = Instance.new("ImageLabel",Ground)
- wat.Size = UDim2.new(0,Size,0,Size)
- wat.Image = "http://www.roblox.com/asset/?id="..158465747-1 --Ground
- wat.Position = UDim2.new(0,Size*(x-1),0,Size*(y-1))
- wat.BackgroundTransparency = 1
- wat.ZIndex = 3
- end
- end
- local Control = Instance.new("TextLabel",UI)
- Control.Size = UDim2.new(0,500,0,20)
- Control.Text = "t = forward, g = backward, f = turn left, h = turn right"
- Control.TextColor3 = Color3.new(0,0,0)
- Control.BackgroundTransparency = 1
- Control.TextScaled = true
- Control.Position = UDim2.new(0.5,-250,0,0)
- Control.ZIndex = 10
- local B={}
- p1=F.Size.X.Offset/2
- p2=F.Size.Y.Offset/2
- LastAngle = 0
- Begin = Vector2.new(0,0)
- function GetDistance(P1,P2)
- return math.sqrt((P1.X-P2.X)^2 + (P1.Y-P2.Y)^2)
- end
- game:GetService("RunService").RenderStepped:connect(function()
- if Player:FindFirstChild("HasCar") and Player:findFirstChild("PlayerGui") then
- CPos = Player.HasCar
- else
- CPos = Instance.new("Vector3Value",Player)
- end
- if not Player:FindFirstChild("PlayerGui") then
- CPos:Remove()
- end
- CPos.Name = "HasCar"
- F.Rotation=Rot--Point(UDim2.new(0,Begin.X,0,Begin.Y),UDim2.new(0,Mouse.X,0,Mouse.Y))
- --F.Position=UDim2.new(0,Begin.X+math.cos(math.rad(F.Rotation))*-25,0,Begin.Y+math.sin(math.rad(F.Rotation))*-25)
- Ground.Position = UDim2.new(0,Begin.X,0,Begin.Y)
- local Dis = (math.abs(F.Rotation-LastAngle))
- Begin = Begin +Velocity
- CPos.Value = Vector3.new(Begin.X,Begin.Y,F.Rotation)
- for i,v in pairs(B) do
- if GetDistance(v.P.AbsolutePosition,v.Point) < 500 then
- v.Position=v.Position+v.Velocity
- else
- v.P.Size = UDim2.new(0,50,0,50)
- v.P.BackgroundColor3 = Color3.new(1,1,0)
- v.P.BackgroundTransparency = 0.5
- game:GetService("Debris"):AddItem(v.P,5)
- end
- v.P.Position = v.Position+UDim2.new(0,Begin.X,0,Begin.Y)
- end
- for i,v in pairs(game.Players:GetPlayers()) do
- if v ~= Player then
- if v:findFirstChild("HasCar") then
- if not FindPlayer(v.Name) then
- NewPlayer(v:findFirstChild("HasCar"))
- print("New Player: " ..v.Name,v:findFirstChild("HasCar").Value)
- end
- end
- end
- end
- for i,v in pairs(Players) do
- v.F.Rotation = v.Pos.Value.Z+180
- v.F.Position = UDim2.new(0.5,v.Pos.Value.X+Begin.X,0.5,v.Pos.Value.Y+Begin.Y)
- v.C.Position = v.F.Position -UDim2.new(0,0,0,30)
- v.C.Text = tostring(v.Pos.Parent)
- v.C.Size = UDim2.new(0,v.C.TextBounds.X,0,v.C.TextBounds.Y)
- if not v.Pos.Parent:IsA("Player") or not v.Pos.Parent:IsDescendantOf(game.Players) then
- table.remove(Players,i)
- v.F:Destroy()
- v.C:Destroy()
- end
- end
- --[[if (Dis > 5 and Dis < 350 and Velocity.magnitude > 5) then
- print(math.abs(F.Rotation-LastAngle),Velocity.magnitude)
- local TrailGui = Instance.new("Frame",UI)
- TrailGui.BackgroundColor3 = Color3.new(0,0,0)
- TrailGui.BackgroundTransparency = 0.5
- TrailGui.Size = UDim2.new(0,5,0,5)
- TrailGui.Position = F.Position+UDim2.new(0,p1,0,p2)
- TrailGui.Rotation = F.Rotation
- game:GetService("Debris"):AddItem(TrailGui,3)
- end]]
- LastAngle = F.Rotation
- Velocity = Velocity*0.95
- end)
- --[[Mouse.Button1Down:connect(function()
- local a={}
- a.P = Instance.new("Frame",UI)
- a.P.Rotation=F.Rotation
- 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
- a.Velocity=-UDim2.new(0,b.X*20,0,b.Y*20)
- a.P.Size=UDim2.new(0,10,0,10)
- a.Position = F.Position+UDim2.new(0,p1,0,p2)
- a.P.Position=a.Position+UDim2.new(0,Begin.X,0,Begin.Y)
- a.Point = F.AbsolutePosition
- table.insert(B,a)
- end)]]
- GD = false
- SD = false
- DD = false
- AD = false
- Mouse.KeyDown:connect(function(k)
- if k == "t" then
- GD = true
- repeat wait()
- Velocity = Velocity -Vector2.new(math.cos(math.rad(F.Rotation)),math.sin(math.rad(F.Rotation)))
- until not GD
- end
- if k == "g" then
- SD = true
- repeat wait()
- Velocity = Velocity +Vector2.new(math.cos(math.rad(F.Rotation)),math.sin(math.rad(F.Rotation)))
- until not SD
- end
- if k == "h" then
- DD = true
- repeat wait()
- if Rot > -1 then
- if Rot < 361 then
- Rot = Rot +0.5*Velocity.magnitude
- else
- Rot = 0
- end
- else
- Rot = 360
- end
- until not DD
- end
- if k == "f" then
- AD = true
- repeat wait()
- if Rot > -1 then
- if Rot < 361 then
- Rot = Rot -0.5*Velocity.magnitude
- else
- Rot = 0
- end
- else
- Rot = 360
- end
- until not AD
- end
- end)
- Mouse.KeyUp:connect(function(k)
- if k == "t" then
- GD = false
- end
- if k == "g" then
- SD = false
- end
- if k == "h" then
- DD = false
- end
- if k == "f" then
- AD = false
- end
- end)
- --[[
- function GetService(v)
- if pcall(function() game:GetService(v) end) then
- return game:GetService(v)
- else
- return nil
- end
- end
- local tab = {}
- tab.__index = function(i,v)
- return game:GetService(v) or _G[v]
- end
- setmetatable(_G,tab)
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement