Hello! So I am trying to insert a named table to another table, is a car spawner, you might understand.
local Index = 1
local MaxAmount = 4
local MinAmount = 1
local Back = script.Parent.Back.TextButton
local Next = script.Parent.Next.TextButton
local Player = game:GetService("Players")["LocalPlayer"]
local OldCar
local Purchase = script.Parent.Frame.Frame.TextButton
local debounce = false
local ok = {
[5] = {name="Ford Mustang GT",price=0}
}
local Templates = {
[1] = {name="Ford Explorer",price=1000},
[2] = {name="Dodge Charger", price=15000},
[3] = {name="Dodge challenger Demon", price=150000},
[4] = {name="2015 Toyota Hilux", price=7900},
}
local Gamepasses = game:GetService("MarketplaceService")
local ID = 7910663
if Gamepasses:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, ID) or game.Players.LocalPlayer.Name == "ignacasas06" then
table.insert(Templates, ok[5])
MaxAmount = 5
end
local Index = 1
local MaxAmount = 4
local MinAmount = 1
local Back = script.Parent.Back.TextButton
local Next = script.Parent.Next.TextButton
local Player = game:GetService("Players")["LocalPlayer"]
local OldCar
local Purchase = script.Parent.Frame.Frame.TextButton
local debounce = false
local ok = {
[1] = {name="Ford Mustang GT",price=0}
}
local Templates = {
[1] = {name="Ford Explorer",price=1000},
[2] = {name="Dodge Charger", price=15000},
[3] = {name="Dodge challenger Demon", price=150000},
[4] = {name="2015 Toyota Hilux", price=7900},
}
local Gamepasses = game:GetService("MarketplaceService")
local ID = 7910663
if Gamepasses:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, ID) or game.Players.LocalPlayer.Name == "ignacasas06" then
table.insert(Templates, ok[1])
MaxAmount = 5
end
Since in the table ok the Ford Mustang GT is not the fitth in the dictionary you had to change [5] to
[1] since its the first info in the table
to check you can use print(Templates[5].name)
if Gamepasses:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, ID) or game.Players.LocalPlayer.Name == "ignacasas06" then
table.insert(Templates, ok[5])
MaxAmount = 5
end
Try changing that to:
if Gamepasses:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, ID) or game.Players.LocalPlayer.Name == "ignacasas06" then
Templates[#Templates + 1] = {name = "Ford Mustang GT",price = 0}
MaxAmount = MaxAmount + 1
end
I basically add a new 5th entry into templates, that’s the Ford Mustang GT. Make sure to update your thing that actually displays the cars, otherwise it might be there, but you cant see it.
Also make sure to add print(Templates[5]) to make sure things work.