Okay so I'm trying to make a script to where I can click on the coffee machine and it gives you the coffee.
This is what I have but it is breaking:
local coffee = script.Parent.Parent
local function OnMouseClick(Player)
coffee = script.Parent.Parent
p = game.Players:GetPlayerFromCharacter(part.Parent)
if p == nil then return end
coffee = game.ServerStorage.Coffee:Clone()
if p.Backpack:FindFirstChild(coffee.Name) ~= nil then return end
coffee.Parent = p.Backpack
print("Enjoy your coffee!")
end
script.Parent.MouseClick:connect(OnMouseClick)
This is my output: 13:49:57.548 - Workspace.Giver.ClickDetector.Script:4: attempt to index global 'part' (a nil value) 13:49:57.549 - Stack Begin 13:49:57.550 - Script 'Workspace.Giver.ClickDetector.Script', Line 4 13:49:57.551 - Stack End
The name of the part you click is 'Giver'.
If you could tell me the error I messed up on the script and not how to fully fix it I would appreciate it because I would still like to learn how to fix it myself :).
