Why wont the apples appear?

while true do
	local s = math.random(1,3)
	print(s)
	if s == 1 then
		local c = script.Parent.APPLE:Clone()
		c.Position = Vector3.new(math.random(-764, -860), 230, 127.5)
	elseif s == 2 then
		local c = script.Parent.Apple:Clone()
		c.Position = Vector3.new(math.random(-764, -860), 230, 127.5)
	elseif s == 3 then
		local c = script.Parent.apple:Clone()
		c.Position = Vector3.new(math.random(-764, -860), 230, 127.5)
	end
	wait(0.5)
end

you need to set its parent to somewhere in workspace

c.Parent = workspace

small nitpick but you dont need all the ifs since they are all doing the same thing, im guessing each apple model is different but it would be easier to pick a random one instead to avoid repeating your script

also use task.wait(0.5)

The issue is that your object names are case sensitive. You have APPLE, Apple, and apple all being cloned separately, but they are checking for three different objects. Make sure all three names match exactly what your object is actually named in the Explorer. If your apple is named Apple, then all three conditions should be cloning Apple, not APPLE or apple.

Also, another thing I noticed is that c.Position will not work on a Model, only a BasePart. If your apple is a Model you will need to use c:SetPrimaryPartCFrame() or move it using PrimaryPart.Position instead.

Pretty sure you’re missing a couple other things, but this is the most I can give.

Thanks, I forgot that i need to set the parent, although i still wont appear…

please could you show your explorer? as @Code_PRANKSTER said you could be using the wrong property or name

yes, the apples are in a model but theyre supposed to be cloned separately

  1. your script should go in ServerScriptService as it does not need to be in ReplicatedStorage
  2. i would also recommend putting the apples inside of the script or make a folder somewhere in ServerStorage

Moreover, it won’t work in ReplicatedStorage :skull:

I don’t mean to be a pedant, but here’s some random thing that came across my mind when I read this and the reply you are referencing:

  • invalid paths would display errors within OP’s code editor in the video
  • the control flow implies there should be different instances they want to clone

OP was vague with their setup as they didnt show console or anything useful so i just assumed they forgot to parent it

The code looks completely fine to me, you should check explorer during testing to confirm they’re not just in the wrong place. Those coordinate ranges are pretty big so it’s not crazy not to see one in a ten second clip.

Assuming they are aware of the ranges they set in the code (it is hard to fake knowing which numbers to use), the jarring obscenity is that their Script is located in ReplicatedStorage :wilted_flower:

And, task.wait() is preferred over wait()

Is this not related to the code in question?

Or, are you using this erroneous script to relocate the one in the main topic post?

I see now. By the way your script in ReplicatedStorage, should be placed over in ServerScriptService.

Just a guess, but are the apples anchored? It looks like in your video the apples are spawning over the void, so it could be possible that the apples fall into the void after spawning in.

theyre unanchored and they are supposed to spawn over a ramp

Then maybe try checking the explorer while in the game, and see if they are spawning in, and then getting deleted. It could be possible that they are spawning in at the wrong position, and then getting deleted by the void.

i did, nothing is changing in the explorer except for “NikolasDB200’s rainbow”

Actually, the problem is what other people have already said. I just tested it, and saw that server scripts do not run in ReplicatedStorage. You would need to move your script to another service. I would recommend ServerScriptService, which is what people have already said.
If you need help moving it, or there is some reason that you don’t want to, tell me why and I can try to help.
That also explains why nothing is being printed in the output.