I created a script that is supposed to clone wheat, it is in replicated storage.
Script:
1 | print ( "works on line 1" ) |
2 | local Wheat = game.ReplicatedStorage.Farm.Wheat:Clone(); print ( "works on line 2" ) |
3 | Wheat.Parent = game.Workspace; print ( "works on line 3" ) |
4 | script:Destroy(); print ( "works on line 4" ) |
5 | print ( "works on line 5" ) |
and it didnt even print on line 1, sorry about this, I never did lua in a while.
this is now how it looks like
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local Farm = ReplicatedStorage:WaitForChild( "Farm" ) |
03 | local Wheat = Farm:WaitForChild( "Wheat" ) |
04 |
05 | local xpos = - 161.75 |
06 | local zpos = 48.375 |
07 | local Count = 0 |
08 | local Count 2 = 0 |
09 | local ifyethappend = true |
10 |
11 | while Count < 32 do |
12 | local WheatClone = Wheat:Clone() |
13 | WheatClone.Parent = game.Workspace |
14 | WheatClone.Name = "Wheat" |
15 | WheatClone.Position = Vector 3. new(WheatClone.Position.x, WheatClone.Position.y, zpos) |
I wrote this exact script into my game just with parts and it worked fine, even placed the part into workspace.
The issue seems to be that you either are trying to get the replicatedstorage.Farm before Farm is actually in the storage or there simply is no such thing as Farm located in replicated storage.
Make sure you place this script into ServerScriptService
1 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
2 | local Farm = ReplicatedStorage:WaitForChild( "Farm" ) |
3 | local Wheat = Farm:WaitForChild( "Wheat" ) |
4 | local WheatClone = Wheat:Clone() |
5 | Wheat.Parent = game.Workspace |
6 | script:Destroy() |
Now, since I don't exactly know your issue I placed a few (Maybe) unnecessary "WaitForChild"s.
Make sure this script is in ServerScriptService and also make sure you actually have Farm and wheat in the correct places!
it ends up, the script was being skiped because it was in replicated storage, now on I will leave it in server script service.