Currently I am working on a burger dispenser (yes, a burger dispenser) and I am coming across a bug. I managed to get the burger dispense the first time, but after that it did not work. The cloning is the problem for me.
Code:
Script 1:
local RS = game:WaitForChild("ReplicatedStorage")
local sandwich = RS:WaitForChild("sanwich")
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = game.Workspace:WaitForChild("Part")
ClickDetector.MouseClick:Connect(function(player)
EB_clickedPlayer = player
local Clone = game.Workspace.CloneBurger
Clone.Value = true
wait(0.09)
Clone.Value = false
print("almost done")
RS.sanwich.Parent = EB_clickedPlayer.Backpack
print("complete")
end)
(CloneBurger is a bool value, I don’t know if that’s the correct way to use them, but I use bool values like broadcast messages in scratch lol)
If you are wondering why there is a “EB_clickedPlayer” I was using event blocks (plugin) to see how the code would be for tracking what player clicked the dispenser
Second script:
while true do
if Clone.Value then
game.ServerStorage.sanwich:Clone()
game.ServerStorage.sanwich:Clone()
game.ServerStorage.sanwich:Clone()
print("cloned")
end
end
Thanks for the help! Please don't give me the whole code, as the whole reason I am doing this is to learn.