So when you click a part Inside the model 'Cup' (which is inside the model, Medium) its supposed to give you a cup, but for some reason its not

for i, part in pairs(workspace.Medium.Cup:GetChildren()) do
	print("cup loaded")
	if part:IsA("Part") then
		mouse.Button1Down:connect(function()
			print("click")
		    local targ = mouse.Target
		    if targ == part then
				print("target")
				game.Lighting.Medium.Cup:Clone().Parent = plr.Backpack
				print("gave")
			end
		end)
	end
end

EDIT: it doesnt print anything

FULL:


plr = game.Players.LocalPlayer
mouse = plr:GetMouse()

for i, model in pairs(workspace.Pizza:GetChildren()) do
	mouse.Button1Down:connect(function()
	    local targ = mouse.Target
	    if targ == model then
			game.Lighting.Pizza:Clone().Parent = plr.Backpack
		end
	end)
end

for i, model in pairs(workspace.Sandwiches:GetChildren()) do
	mouse.Button1Down:connect(function()
	    local targ = mouse.Target
	    if targ == model then
			game.Lighting.Sandwich:Clone().Parent = plr.Backpack
		end
	end)
end

for i, part in pairs(workspace.Small.Cup:GetChildren()) do
	mouse.Button1Down:connect(function()
	    local targ = mouse.Target
	    if targ == part then
			game.Lighting.Small.Cup:Clone().Parent = plr.Backpack
		end
	end)
end

for i, part in pairs(workspace.Medium.Cup:GetChildren()) do
	print("cup loaded")
	if part:IsA("Part") then
		mouse.Button1Down:connect(function()
			print("click")
		    local targ = mouse.Target
		    if targ == part then
				print("target")
				game.Lighting.Medium.Cup:Clone().Parent = plr.Backpack
				print("gave")
			end
		end)
	end
end

for i, part in pairs(workspace.Large.Cup:GetChildren()) do
	mouse.Button1Down:connect(function()
	    local targ = mouse.Target
	    if targ == part then
			game.Lighting.Large.Cup:Clone().Parent = plr.Backpack
		end
	end)
end

10 comments

0

Does output give any errors?

0

nope

0

Can you add your full script?

0

Is the script under ServerStorage, Lighting, or disabled?

0

Its a localscipt in a players starterscripts, and ill add the full thing

0

Try putting it in StarterPack or StarterGui.

0

Didnt work

0

btw its just the cups for some reason

0

I tried it in studio, it worked for me. Do you got a picture of the explorer(Not sure what it's called, the directory their all in.)?

0

well i fixed the 'Form' directory but still nothing, https://gyazo.com/5b9a401546ef50a5dda071f3bd2000df