ProximityPrompts not enabling, throwing error message

local function Deactivate()
	for i,v in pairs(workspace.Builds.Campfires:GetChildren()) do
		v.MountingRod.Cook.Enabled = false
	end
end

This client function is supposed to disable all the proximity prompts connected to campfires. However, v.MountingRod.Cook.Enabled = false throw the error message: "invalid argument #2 (string expected, got Instance) " I checked, and v is a campfire model, so everything should line up.
image

You need to make a check if the instances found during the loop is a ProximityPrompt. Also, it’s better to use GetDescendants() in this situation.

local function Deactivate()
	for i, v in pairs(workspace.Builds.Campfires:GetDescendants()) do
		if v:IsA("ProximityPrompt") then -- checks if the instance is a ProximityPrompt
			v.Enabled = false -- disables all ProximityPrompts under the 'Campfire' model
		end
	end
end

Would this check children of children in the model, since the prompt is inside one of the parts in the model?

GetDescendants() will return every instance under the specified part. GetChildren() will only return the immediate children of the specified part.

Ohhhhh alright. Never used this before. Thank you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.