Hello, I’m working on a Halloween Event for my game which will have raining candies. I talked to some people in a scripting help Discord server and this is as far as we got.
for i = 1,100 do
local candy = game:GetService("ServerStorage"):WaitForChild("Candy")
candy.Position = Vector3.new(math.random(-120,120),100,math.random(-120,120))
candy:Clone()
candy.Parent = workspace
end
It seems that you don’t have the candy object in ServerStorage, as it is not being found. Are you sure you have already places your candy model inside of ServerStorage?
Also, make sure that the model isn’t anchored to that it will fall, unless you want to use another method of falling.
for i = 1,100 do
wait()
local candy = game.ServerStorage:WaitForChild("Candy"):Clone()
candy.Position = Vector3.new(math.random(-120,120),100,math.random(-120,120))
candy.Parent = workspace
end
If it is yielding infinitely, that means Candy is not a member of ServerStorage. You need to insert the candy instance you want into server storage.
For example:
local candy = Instance.new("Part")
candy.Name = "Candy"
candy.Parent = game:GetService("ServerStorage")
If you have a predefined or placed instance of Candy, make sure it is directly parented to ServerStorage and named Candy. If you are calling on the client, you will not be able to see anything inside ServerStorage as it does not replicate.
If you are needing to do this on the client, I recommend storing the Instance Candy inside ReplicatedStorage.
Can’t you just do repeat wait() until game:GetService("ServerStorage"):WaitForChild("Candy")? And then afterwards can’t you do local candy = game:GetService(“ServerStorage”):WaitForChild(“Candy”)?