function generateMedKit(name,XYZ) local MedKits = game.ServerStorage.MedKits.name MedKits.Position = XYZ MedKits.Parent = game.Workspace end generateMedKit("Med1","Vector3.new(463.39, 28.452, 220.52)") generateMedKit("Med2","Vector3.new(463.39, 28.452, 208.84)") generateMedKit("Med3","Vector3.new(463.39, 28.452, 196.33)")
I understand what is not working here, but I am not sure how to fix it. The variable is being set to "game.ServerStorage.MedKits.name", but I need the script to make "name" whatever I write within the argument like "Med1" that way for each function I call I can select a different part within the ServerStorage.
function generateMedKit(name,XYZ) local partName = name local MedKits = game.ServerStorage.MedKits.partName MedKits.Position = XYZ MedKits.Parent = game.Workspace end generateMedKit("Med1","Vector3.new(463.39, 28.452, 220.52)") generateMedKit("Med2","Vector3.new(463.39, 28.452, 208.84)") generateMedKit("Med3","Vector3.new(463.39, 28.452, 196.33)")
I also tried doing it this way trying make "partName" a variable of the "name" I wanted, but it didn't work.
Sorry if it is hard to understand what I'm asking, I just started scripting and can't explain this stuff well yet. I'm not even sure if any of this script could even work.
Use :FindFirstChild(name)
function generateMedKit(name, XYZ) local MedKits = game.ServerStorage.MedKits:FindFirstChild(name) MedKits.Position = XYZ MedKits.Parent = game.Workspace end generateMedKit("Med1","Vector3.new(463.39, 28.452, 220.52)") generateMedKit("Med2","Vector3.new(463.39, 28.452, 208.84)") generateMedKit("Med3","Vector3.new(463.39, 28.452, 196.33)")
Accept the answer if it helped you!