What do I want to achieve?
I want to create a variable that contains multiple models, So I will be able to modify all of their Proximity Prompt properties from 1 script without creating many variables for each and every single one of them.
What is the issue?
It would only work on ONE model in the workspace
What solutions have I tried so far?
This is the current working script
local Tool = script.Parent
local ProximityPrompt = game:GetService("ProximityPromptService")
local LavHarvest = workspace.Lavender.leaves.LavenderHarvest
Tool.Equipped:Connect(function()
LavHarvest.Enabled = true
end)
Tool.Unequipped:Connect(function()
LavHarvest.Enabled = false
end)
return
but for what I tried of messing around with multiple methods I found on the dev forum. but I haven’t managed to get it to work
You could also just put all of the Lavender in a folder and just loop through all of the children of the folder like this.
local Tool = script.Parent
local ProximityPrompt = game:GetService("ProximityPromptService")
local LavFolder = --Define path to folder here
Tool.Equipped:Connect(function()
for i, lavender in pairs(LavFolder:GetChildren()) do
lavender.leaves.LavenderHarvest.Enabled = true
end
end)
Tool.Unequipped:Connect(function()
Tool.Equipped:Connect(function()
for i, lavender in pairs(LavFolder:GetChildren()) do
lavender.leaves.LavenderHarvest.Enabled = false
end
end)
end)
Thanks! I usually organize my maps in folders so using this method is very helpful to me.
There was a mistake in line 10 where you typed a function twice so it kind of bugged:
local Tool = script.Parent
local ProximityPrompt = game:GetService("ProximityPromptService")
local LavFolder = workspace.Lavenders
Tool.Equipped:Connect(function()
for i, lavender in pairs(LavFolder:GetChildren()) do
lavender.leaves.LavenderHarvest.Enabled = true
end
end)
Tool.Unequipped:Connect(function()
for i, lavender in pairs(LavFolder:GetChildren())do
lavender.leaves.LavenderHarvest.Enabled = false
end
end)
I have also tried Collection Services but it didn’t work out for me for some reason, but this folder method is way better for me personally.