Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Vehicles = workspace.Vehicles
- local function Notification(Title, Description)
- game:GetService("StarterGui"):SetCore("SendNotification", {
- Title = Title,
- Text = Description
- })
- end
- local Gui = Instance.new("ScreenGui")
- Gui.Parent = game.Players.LocalPlayer.PlayerGui
- Gui.ResetOnSpawn = false
- local Button = Instance.new("TextButton", Gui)
- Button.BackgroundTransparency = 1
- Button.TextScaled = true
- Button.TextColor3 = Color3.fromRGB(255, 255, 255)
- Button.Text = "Go to your car"
- Button.Size = UDim2.new(0.2, 0, 0.05, 0)
- Button.Position = UDim2.new(0.4, 0, 0, 0)
- local function SetupCarInteractions()
- for _, vehicle in ipairs(Vehicles:GetChildren()) do
- local clickDetector = vehicle:FindFirstChild("ClickDetector")
- if not clickDetector then
- clickDetector = Instance.new("ClickDetector")
- clickDetector.Parent = vehicle
- clickDetector.MaxActivationDistance = math.huge
- end
- if not clickDetector:GetAttribute("Connected") then
- clickDetector.MouseClick:Connect(function()
- local car = clickDetector.Parent
- if car then
- if car.DriveSeat:FindFirstChild("SeatWeld") then
- Notification("Error", "The car you've been trying to enter currently has a driver named " .. car.Name .. ".")
- else
- car.DriveSeat:Sit(game.Players.LocalPlayer.Character.Humanoid)
- end
- end
- end)
- clickDetector:SetAttribute("Connected", true)
- end
- end
- end
- Button.Activated:Connect(function()
- if Vehicles:FindFirstChild(game.Players.LocalPlayer.Name) then
- Vehicles[game.Players.LocalPlayer.Name].DriveSeat:Sit(game.Players.LocalPlayer.Character.Humanoid)
- end
- end)
- task.spawn(function()
- while task.wait(0.5) do
- SetupCarInteractions()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement