Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why wont my script even read line 1? ReplicatedStorage

Asked by
xxaxxaz 42
3 years ago
Edited 3 years ago

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()
0
please answer xxaxxaz 42 — 3y
0
Any errors in the output? MarkedTomato 810 — 3y
0
nope xxaxxaz 42 — 3y

2 answers

Log in to vote
1
Answered by 3 years ago

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!

0
ohhhhhh. XD I forgot to do wait for child. Thank you so much! xxaxxaz 42 — 3y
0
btw, Local Farm = ReplicatedStorage:WaitForChild("Wheat") instead xxaxxaz 42 — 3y
0
nvm, it didnt work xxaxxaz 42 — 3y
0
Are you sure you have the script in the right location and actually have the two parts or models in replicated storage? tightanfall 110 — 3y
View all comments (5 more)
0
the first part is a model named "Farm", inside there is the Wheat block. xxaxxaz 42 — 3y
0
and if it helps, this script is also inside of the model xxaxxaz 42 — 3y
0
yes xxaxxaz 42 — 3y
0
I just replaced the model with a folder xxaxxaz 42 — 3y
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 tightanfall 110 — 3y
Ad
Log in to vote
0
Answered by
xxaxxaz 42
3 years ago

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

0
I said that in my answer but ok tightanfall 110 — 3y
0
oh... xxaxxaz 42 — 3y
0
oh... xxaxxaz 42 — 3y
0
oh... xxaxxaz 42 — 3y
0
weird, when I did this it for some reason said my text 3 times xxaxxaz 42 — 3y

Answer this question