I’m trying to make pieces of food that can be collected with proximity prompts and I can stack them 0.25 studs over each other to make my own food but the problem is I want there to be a limit. I know that I can use a while loop or maybe a repeat until so that it can repeat/update itself to acquire the desired result but I don’t think that is the right way to script it. I’ve tried moving around the if statement which says if my part containing the proximity prompt that places the food parts is in a certain position, it will unenable the proximity prompt that brings food on the plate. This position is based on how much parts there are on the plate.
local part = workspace.PlateInteraction1
print(part.Position)
local rs = game:GetService("ReplicatedStorage")
local folder = rs.PartsFolder.PlacingParts
local placingfolder = workspace.PlacingPartsFolder:GetChildren()
part.ProximityPrompt.Triggered:Connect(function(plr)
local num = -0.375
local num2 = 0.25
local char = plr.Character
local tool = char:FindFirstChildWhichIsA("Tool")
local handle = tool.Handle
if tool.Name == "Meat" or "Lettuce" or "Cheese" then
for i,v in pairs(folder:GetChildren()) do
if v.Name == tool.Name then
local foodpart = v:Clone()
print("Cloned")
if part.Position == part.Position then
foodpart.Parent = workspace.PlacingPartsFolder
foodpart.Position = part.Position + Vector3.new(0,num,0)
part.Position = part.Position + Vector3.new(0,num2,0)
tool:Destroy()
else
part.Position = Vector3.new(32.375,part.Position.Y + num2,15.25)
foodpart.Position = part.Position
foodpart.Position = foodpart.Position + Vector3.new(0,num,0)
end
if part.Position == Vector3.new(32.375, 6, 15.25) then
part.ProximityPrompt.Enabled = false
end
end
end
end
end)