It does not show any errors but the part is not spawing
Which number you typed to attribute?It should be 0.
It didn’t work :((((((((((((( anything else?
yea I added 0 as you said it doesn’t work
Add print after if spawned < 5 then. And look if it prints.
it worked but dough didn’t spawn
I quickly went ahead and reorganized your script and added a few debugging logs.
Could you try to run this and tell us the result in output?
--| Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--| Variables
local Spawner = script.Parent
--| Methods
function SpawnDough()
if not ReplicatedStorage:FindFirstChild("DoughPart") then
warn("Couldn't find Dough Part"); return nil
end
local myDough = ReplicatedStorage.DoughPart:Clone()
myDough.Parent = workspace
myDough.Position = Spawner.Position
return myDough
end
while task.wait(2) do
local Spawned = Spawner:GetAttribute("DoughSpawned")
if not Spawned or typeof(Spawned) ~= "number" then Spawned = 0; Spawner:SetAttribute("DoughSpawned", 0) end --| Ensures its not nil and replaces with 0
if Spawned and Spawned < 5 then
local myDough = SpawnDough()
Spawner:SetAttribute("DoughSpawned", Spawner:GetAttribute("DoughSpawned") + 1)
warn("Spawned a dough.")
else
warn("Spawned is above 4.")
end
end
Try to print dough.Parent and also is it anchored?
1 Like
You need to fix it a little bit
Damn yea it was anchored my bad anyways thank you you are the solution!
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.