so i made a script that receives a remove event, this is the line:
SpawnCarEvent.OnServerEvent:Connect(function(player, carName)
CarName is associated to a car that you chose in an other script. is made a line that associates the cars names to image ids:
local CarImageIds = {
[6068169587] = "Beige Dune Buggy" ,
[109662003] = "Black Jeep" ,
[242143853] = "Black Sedan" ,
[8382532839] = "Blue SUV" ,
[126103845] = "Ford Shelby Truck" ,
[4072026855] = "Green camo Jeep" ,
[3142634] = "Lamborghini Aventador SVJ" ,
[7225067642] = "Pink Jeep" ,
[7141615506] = "Police Car" ,
[28261053] = "Red Maserati Car" ,
[6881212666] = "Red Sedan" ,
[7262556994] = "White Van" ,
}
how do i make the CarImageIds = the CarName
If you dont understand, i could explain, just tell me.
Heres the script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnCarEvent = ReplicatedStorage:WaitForChild("SpawnCar")
local DeleteCarEvent = ReplicatedStorage:WaitForChild("DeleteCar")
local CarSpawnNotificationEvent = ReplicatedStorage:WaitForChild("CarSpawnNotification")
local CarImageIds = {
[6068169587] = "Beige Dune Buggy" ,
[109662003] = "Black Jeep" ,
[242143853] = "Black Sedan" ,
[8382532839] = "Blue SUV" ,
[126103845] = "Ford Shelby Truck" ,
[4072026855] = "Green camo Jeep" ,
[3142634] = "Lamborghini Aventador SVJ" ,
[7225067642] = "Pink Jeep" ,
[7141615506] = "Police Car" ,
[28261053] = "Red Maserati Car" ,
[6881212666] = "Red Sedan" ,
[7262556994] = "White Van" ,
}
SpawnCarEvent.OnServerEvent:Connect(function(player, carName)
local Car = ServerStorage:FindFirstChild("Cars"):FindFirstChild(carName)
if Car then
local clonedCar = Car:Clone()
clonedCar.Name = player.Name .. 'sCar'
clonedCar.Parent = game.Workspace
clonedCar:MoveTo(player.Character.HumanoidRootPart.Position + player.Character.HumanoidRootPart.CFrame.LookVector * 15)
local CarImage = CarImageIds(carName)
CarSpawnNotificationEvent:FireClient(carName)
end
end)
DeleteCarEvent.OnServerEvent:Connect(function(player, Car)
if Car then
Car:Remove()
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local Car = game.Workspace:FindFirstChild(player.Name .. 'sCar')
if Car then
Car:Remove()
end
end)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Car = game.Workspace:FindFirstChild(player.Name .. 'sCar')
if Car then
Car:Remove()
end
end)
end)