Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why wont my script even read line 1? ReplicatedStorage

I created a script that is supposed to clone wheat, it is in replicated storage.

Script:

print("works on line 1")
local Wheat = game.ReplicatedStorage.Farm.Wheat:Clone(); print("works on line 2")
Wheat.Parent = game.Workspace; print("works on line 3")
script:Destroy(); print("works on line 4")
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

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Farm = ReplicatedStorage:WaitForChild("Farm")
local Wheat = Farm:WaitForChild("Wheat")

local xpos = -161.75
local zpos = 48.375
local Count = 0
local Count2 = 0
local ifyethappend = true

while Count < 32 do
	local WheatClone = Wheat:Clone()
	WheatClone.Parent = game.Workspace
	WheatClone.Name = "Wheat"
	WheatClone.Position = Vector3.new(WheatClone.Position.x, WheatClone.Position.y, zpos)
	while Count2 < 32 do
		local WheatClone2 = WheatClone:Clone()
		WheatClone2.Parent = game.Workspace
		WheatClone2.Name = "Wheat"
		if ifyethappend == true then
			WheatClone2.Position = Vector3.new(xpos, WheatClone.Position.y, WheatClone.Position.z)
			ifyethappend = false
		else
			WheatClone2.Position = Vector3.new(xpos, WheatClone2.Position.y, WheatClone2.Position.z)
		end
		
		xpos = xpos - 3
		Count2 = Count2 + 1
		if Count2 == 31 then
			ifyethappend = true
		end
	end
	xpos = -161.75
	zpos = zpos - 3
	Count = Count + 1
	Count2 = 0
end

local Count = 0

script:Destroy()

3 comments

0

please answer

0

Any errors in the output?

0

nope

2 answers

✓ Accepted answer

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

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Farm = ReplicatedStorage:WaitForChild("Farm")
local Wheat = Farm:WaitForChild("Wheat")
local WheatClone = Wheat:Clone()
Wheat.Parent = game.Workspace 
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!

9 comments

0

ohhhhhh. XD I forgot to do wait for child. Thank you so much!

0

btw, Local Farm = ReplicatedStorage:WaitForChild("Wheat") instead

0

nvm, it didnt work

0

Are you sure you have the script in the right location and actually have the two parts or models in replicated storage?

0

the first part is a model named "Farm", inside there is the Wheat block.

0

and if it helps, this script is also inside of the model

0

yes

0

I just replaced the model with a folder

0

I would make sure that the wheat block is already in the correct position in the workspace before placing into the folder. that way it will clone to the same position

it ends up, the script was being skiped because it was in replicated storage, now on I will leave it in server script service.

5 comments

0

I said that in my answer but ok

0

oh...

0

oh...

0

oh...

0

weird, when I did this it for some reason said my text 3 times

This discussion is preserved as it was. New answers, comments, and votes are closed.