I've been trying to make food machines. If you don't know what food mahines are, they are the givers that give food in restaurants/cafes in roblox. I followed a video to try to make a drink, and I followed and did all the scripts, but I need help with the script that when you click the cup model so it can give you the cup in your hand, when I click it, it gives me a tool that says "Cup", but once I click the tool, nothing shows up. Scripts:
script.Parent.Touched:connect(function(h)
if h.Parent.Name == "Cup" then
h.Parent.Name = "Cherry Slurpee"
h.Parent.Top.Transparency = 0
h.Parent.Middle.Transparency = 0
h.Parent.Bottom.Transparency = 0
end
end)
local RemoteEvents = game:GetService("ReplicatedStorage"):WaitForChild("Events")
local Give = RemoteEvents:WaitForChild("Give")
Give.OnServerEvent:connect(function(player, Tool)
local Tool = game:GetService("ServerStorage"):WaitForChild(Tool)
local ToolClone = Tool:Clone()
ToolClone.Parent = player.Backpack
end)
local prev
local parts = script.Parent:GetChildren()
for i = 1, #parts do
if ((parts[i].ClassName == "Part") or (parts[i].className == "Handle") or (parts[i].className == "WedgePart") or (parts[i].className == "WedgePart") or (parts[i].className =="Seat")or (parts[i].className == "WedgePart") or (parts[i].className == "TrussPart")or (parts[i].className == "VehicleSeat") or (parts[i].className =="UnionOperation") or (parts[i].className == "SkateboardPlatform")) then
if (prev ~= nil) then
local weld = Instance.new("Weld")
weld.Part0 = prev
weld.Part1 = parts[i]
weld.C0 = prev.CFrame:inverse()
weld.C1 = parts[i].CFra,e:inverse()
weld.Parent = prev
parts[i].Anchored = false
end
prev = parts[i]
end
end
wait(3)
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
local Give = game:GetService("ReplicatedStorage").Events:WaitForChild("Give")
Mouse.Button1Down:connect(function()
if Mouse.Target == nil then return end
if Mouse.Target:FindFirstChild("ClickDetector") then
Give:FireServer(Mouse.Target.Name)
end
end)
If you understand what I am asking please help and answer. Thank you for helping.

2 comments
Have the tool clone to the player's character rather than their toolbox.
use codeblck