So I made a car but I want multiple to be in use in my game. The scripts run by checking who owns the car (checking the CarName value) and checking if the car’s model name is the players name.
Here is the script I have (located in the A-Chassis Tune script)
if script.Parent.Parent.DriveSeat:IsA("VehicleSeat") then
script.Parent.Parent.DriveSeat.ChildAdded:connect(function(child)
if child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
local p=game.Players:GetPlayerFromCharacter(child.Part1.Parent)
local g=script.SirenControl:Clone()
g.Parent=p.PlayerGui
g.Frame.CarName.Value = p.DisplayName
local car = game.Workspace:WaitForChild(script.Parent.Parent)
car.Name = g.CarName.Value
script.Parent.Parent.DriveSeat.Changed:Connect(function()
if script.Parent.Parent.DriveSeat.Occupant == nil then
local sirencontrol = p.PlayerGui:FindFirstChild("SirenControl")
if sirencontrol then
sirencontrol:Destroy()
end
end
end)
end
end)
end
g.Frame.CarName.Value = p.DisplayName – g = SirenControl GUI
local car = game.Workspace:WaitForChild(script.Parent.Parent) – Finding the car in the game while not specifying the name.
car.Name = g.CarName.Value – Changing the car’s name to the value name of CarName (players name)
Error
Infinite yield possible on 'Workspace:WaitForChild("Instance")' – When finding the car
Is there a way I can locate the car and change it’s name?