You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Im am trying to make a working griddle stove, but I’ve stumbled upon a problem as per the video below I want it so when the patty is clicked it spawns on top of the grill where the red blocks are located. It works but only spawns at one of the red box. I also notice that when I set the attribute back to true it sets all of the values attribute to true. -
What is the issue? Include screenshots / videos if possible!
robloxapp-20230321-1504022.wmv (1.1 MB) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
So far only solutions I have done is tried to switch the code around to see if change, but I feel it something minimal. I just can’t see it.
local griddle = workspace.Griddle
local ingredients = workspace.Ingredients -- Folder for the patties
local FoodPlaceHolderArray = griddle.FoodPlaceHolder -- Folder for the redboxes
local SoundService = game:GetService("SoundService")
local frying = SoundService.GrillFeedBackSounds.Frying
-- This function teleports the patty to the grill once the Patty is clicked on.
local function sendPattyToGrill(object)
for _, placeHolder in pairs(FoodPlaceHolderArray:GetChildren())do
if placeHolder:GetAttribute("Occupied") == false then -- Checks if the redbox is occupied
object.Position = placeHolder.Position -- teleport patty to the space
placeHolder:SetAttribute("Occupied", true) --
end
frying:Play()
placeHolder:SetAttribute("Occupied", false)
end
end
for _, v in pairs(ingredients:GetChildren()) do
v.ClickDetector.MouseClick:Connect(function()
sendPattyToGrill(v)
end)
end