Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

can someone help me with this vending machine please?

ok, I have designed a few machines and I have one that works.

I wanted a bigger one so a made one 2x the size ( everything is made the same)

I used the same script.

the small one works , but the large one don't.

can anyone see what is wrong with this so the large one will work.

I don't understand why the small one works but the large one wont.

it keeps giving me an error

21:28:03.959 - Workspace.MyVendingMachineThree.ImportantParts.Script:2: attempt to index a nil value

21:28:03.959 - Stack Begin

21:28:03.959 - Script 'Workspace.MyVendingMachineThree.ImportantParts.Script', Line 2 - global onClicked

21:28:03.960 - Script 'Workspace.MyVendingMachineThree.ImportantParts.Script', Line 11

21:28:03.960 - Stack End

function onClicked(Name, Holder)
   local DOF = game.Lighting.DrinkandFood:findFirstChild(Name):clone()
   DOF.Parent = game.Workspace
   DOF.Handle.CFrame = Holder.CFrame
   DOF.Handle.Anchored = false
end

local c = script.Parent:GetChildren()
for i = 1, #c do
   if c[i].className == "Part" then
      c[i].ClickDetector.MouseClick:connect(function() onClicked(c[i].Name, c[i].Holder)end)
   end
end 

thanks for the help

as well here is the path to everything...

Workspace
		MyVendingMachineThree
	Lighting

those are the ones needed both the machine and lighting are under workspace right now. but that shouldnt really matter

1 answer

Are you sure there is a MyVendingMachineThree in lighting? Check for typos. Also you shouldn't store those things in lighting anymore, as roblox has created ReplicatedStorage.

3 comments

0

I have never used that before how do you use that instead?

0

i finally fixed this problem. i had 2 DrinkandFood folders in my Lighting.... lol... oops! ( so how do i change to use the ReplicatedStorage instead?

0

All you need to do is move the the stuff you have stored in lighting and move it into replicated storage, change the variables, and bam. Honestly you can do a few cool things, with it, but for now, just move everything over. The wiki has an article on it if you're really interested

This discussion is preserved as it was. New answers, comments, and votes are closed.