Local obj = game.ServerStorage.Drops.Coal ---> local obj = game.ServerStorage.Drops.(droptype)

Instead of exactly going to the item I want dropped, I am trying to drop the same item, with a variable, so that it can be changed easily later. If there is a way to do this, I don’t know how. I tried changing .Coal to .(droptype) but as you can see that does not work.

local droptype = "Coal"

deb = true 
	if deb == true then
		deb = false
		--local part = game:GetService("ServerStorage"):WaitForChild(droptype):Clone()
		local obj = game.ServerStorage.Drops.(droptype)
		local part = obj:Clone()
		part.Parent = game.Workspace:WaitForChild("PartStorage")
		local cash = Instance.new("IntValue",part)
		cash.Name = "Cash"
		cash.Value = 2 -- How much the drops are worth
		part.CFrame = script.Parent.Drop.CFrame - Vector3.new(0,1.3,0)
		game.Debris:AddItem(part,20) -- How long until the drops expire
		deb = true

Thank you for any help in advance

You should use brackets []:

local obj = game.ServerStorage.Drops[droptype]
1 Like