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

wait()
ReplicatedStorage = game:GetService("ReplicatedStorage")
floraEvent = ReplicatedStorage:WaitForChild("floraEvent")
flora =  ReplicatedStorage:WaitForChild("Flora")


function generateFlora(targ,node)
    local plant = flora:FindFirstChild(targ)  
        local p2 = plant:Clone() 
    p2.Parent = game.Workspace 
    p2.PrimaryPart.CFrame = node.CFrame

end 

floraEvent.OnClientEvent:Connect(function(...)
    local args = {...}
    for _, arg in pairs(args) do
        print(args[1].Name.."Located") 
    end

wait(.1) print (args[4]) print (args[5]) local v = args[4]
  generateFlora(v,args[5]) 

end)

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 ;)

wait(2)
ReplicatedStorage = game:GetService("ReplicatedStorage")
floraEvent = ReplicatedStorage:WaitForChild("floraEvent")
flora =  ReplicatedStorage:WaitForChild("Flora")


function generateFlora(targ,node)
    local plant = flora:FindFirstChild("medBushA")  
        local p2 = plant:Clone() 
    p2.Parent = game.Workspace 
    print("Planted!")
--  p2.PrimaryPart.CFrame = node.CFrame

end 

floraEvent.OnClientEvent:Connect(function(...)
    local args = {...}
    for _, arg in pairs(args) do
        print(args[1].Name.."Located") 
    end

wait(.1) print (args[4]) print (args[5]) 
local v = args[4]
generateFlora(v, args[5]) 
end)
Ad

Answer this question