
Keyless

-- The script teleports only when you get into the car and run the script, to stop the script just get out of the car
-- Get the current player
local player = game.Players.LocalPlayer
-- Check that the player exists
if player then
-- Get the player ID
local playerID = player.UserId
- Function for finding the player's car by ID via the PlayerId attribute
function findPlayerCarByID(playerID)
for _, car in pairs(game.Workspace.Cars:GetChildren()) do
if car:IsA("Model") and car:GetAttribute("PlayerId") then
local ownerID = car:GetAttribute("PlayerId")
if ownerID == playerID then
return car
end
end
end
return nil
end
- Find the player's car
local playerCar = findPlayerCarByID(playerID)
if playerCar then
-- Set the PrimaryPart of the car if it is not done in the game
playerCar.PrimaryPart = playerCar:FindFirstChild("Chassis")
-- Function for teleporting the car by coordinates
function teleportCarToPosition(targetCFrame)
if playerCar and playerCar.PrimaryPart then
playerCar:SetPrimaryPartCFrame(targetCFrame)
end
end
-- Function for teleporting to each coin
function teleportToCoins()
-- Find the folder with coins
local coinsFolder = game.Workspace.CoinsSetup.CoinsFolder
-- Loop through all the coins in the folder
for _, coin in ipairs(coinsFolder:GetChildren()) do
-- Check if the object has a CFrame (it should be a coin)
if coin:IsA("BasePart") then
-- Get the current coordinates of the coin
local coinPosition = coin.Position
-- Add 5 units to the height (y-coordinate)
local newPosition = Vector3.new(coinPosition.X, coinPosition.Y + 1, coinPosition.Z)
-- Teleport the car to the new position
teleportCarToPosition(CFrame.new(newPosition))
wait(0.2) -- A small delay between teleports
end
end
end
-- The main function that will be repeated when all coins are processed
while true do
-- Teleport to the coins
teleportToCoins()
end
end
end
ai
it still works