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

why is Flora defined, but still nil?

Asked by
Chronomad 180
7 years ago

Flora is defined, but when I try to call it I get nil. Any ideas?

Client

01wait()
02ReplicatedStorage = game:GetService("ReplicatedStorage")
03floraEvent = ReplicatedStorage:WaitForChild("floraEvent")
04flora =  ReplicatedStorage:WaitForChild("Flora")
05 
06 
07function generateFlora(targ,node)
08    local plant = flora:FindFirstChild(targ) 
09        local p2 = plant:Clone()
10    p2.Parent = game.Workspace
11    p2.PrimaryPart.CFrame = node.CFrame
12 
13end
14 
15floraEvent.OnClientEvent:Connect(function(...)
View all 24 lines...

Server

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

Your code is going like this, it seems that your generate function cant check the variables targ, and node.

So now it will say: local plant = flora:FindFirstChild("medBushA") (instead of) local plant = flora:FindFirstChild(targ) targ isn't a thing but you still trying to find it in your flora folder, and for the p2.PrimaryPart.CFrame = node.CFrame, it's littery the same thing cause node is a variable and a variable doesn't have a CFrame, but yeah here is the correct code you can test it and leave me a like if it worked ;)

01wait(2)
02ReplicatedStorage = game:GetService("ReplicatedStorage")
03floraEvent = ReplicatedStorage:WaitForChild("floraEvent")
04flora =  ReplicatedStorage:WaitForChild("Flora")
05 
06 
07function generateFlora(targ,node)
08    local plant = flora:FindFirstChild("medBushA"
09        local p2 = plant:Clone()
10    p2.Parent = game.Workspace
11    print("Planted!")
12--  p2.PrimaryPart.CFrame = node.CFrame
13 
14end
15 
View all 25 lines...
Ad

Answer this question