Hello Roblox Developers!
My script finds every Jeep in the Raceway folder and finds Configurations > Speed and increases the value of Speed by 25.
However, it doesn’t work, and I can’t find a solution!
Script:
rep.FasterCars.OnServerEvent:Connect(function(player)
for i, v in pairs(game.Workspace.Raceway.Jeep:GetChildren()) do
if v.Name == "Configurations" then
local iv = v:GetChildren()
if iv.Name == "Speed" then
iv.Value += 25
end
end
end
end)
Thats a table, you have to use for pairs loop again.
rep.FasterCars.OnServerEvent:Connect(function(player)
for i, v in pairs(game.Workspace.Raceway.Jeep:GetChildren()) do
if v.Name == "Configurations" then
local iv = v:GetChildren()
for index,value in pairs(iv) do
if value.Name == "Speed" then
value.Value += 25
end
end
end
end
end)
Maybe your speed is in other parent that :GetChildren isnt reaching to?
Use Instance:GetDescendants() to get each item in a model or a folder.
rep.FasterCars.OnServerEvent:Connect(function(player)
for i, v in pairs(game.Workspace.Raceway.Jeep:GetDescendants()) do
if v.Name == "Speed" then
v.Value += 25
end
end
end)
Thank you, your post worked and synitx too so i combined both your ideas and it worked! I have to give the credit to you though because thats the one that actually sparked the main problem.