Im trying to create a dropper in a tycoon game but im getting the error "attempt to index nil with ‘dropTemplate’ " because of line 12 and i dont know why. The Attribute in question is named Acacia and should be getting the part named Acacia
ive already tried replacing the brackets with :FindFirstChild and :WaitForChild but it creates the same error
local dropsFolder = game:GetService("ServerStorage").Drops
local Debris = game:GetService("Debris")
local Dropper = {}
Dropper.__index = Dropper
function Dropper.new(tycoon, instance)
local self = setmetatable({}, Dropper)
self.Tycoon = tycoon
self.Instance = instance
self.Rate = instance:GetAttribute("Rate")
self.DropTemplate = dropsFolder[instance:GetAttribute("Drop")]
self.DropSpawn = instance.Spout.Spawn
return self
end
function Dropper:Init()
coroutine.wrap(function()
while true do
self.Drop()
wait(self.Rate)
end
end)()
end
function Dropper:Drop()
local Drop = self.DropTemplate:Clone()
Drop.Position = self.DropSpawn.WorldPosition
Drop.Parent = self.Instance
Debris:AddItem(Drop, 10)
end
return Dropper
Please Help!