Hiya devs I am making a thing where a player can order food and then another player serves it, however the issue I am getting is that the script can not find the tool
script:
script.Parent.ServeButton.MouseButton1Click:Connect(function()
if script.Parent.Premium.Text == "true" then
local foodtools = game.ReplicatedStorage.IFE.PremiumFoodItems[script.Parent.Main.Text.." | "..script.Parent.Drink.Text.." | ".. script.Parent.Dessert.Text]:Clone()
foodtools.Parent = game.Players:WaitForChild(script.Parent.PlrName.Text).Backpack
end
end)
1.I Suggest doing this from a server script [using a remote event].
2.Have at top of your script variables and services to make your lines shorter and more efficient.
Iâll now fix your code.
Try this:
--client
--//Services
local Players= game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
--//Variables
local Remote = Replicated:WaitForChild("GiveTool")
local Button = script.Parent
--//Functions
local function GiveTool()
if script.Parent.Premium.Text == "true" then
Remote:FireServer(script.Parent.PlrName.Text)
end
end
--//Logic
Button.MouseButton1Click:Connect(GiveTool)
---Server
--//Services
local Players= game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
--//Variables
local Remote = Replicated:FindFirstChild("GiveTool")
--//Logic
Remote.OnServerEvent:Connect(function(Player,Target)
if not Players:FindFirstChild(Target) then return end
local Tool = Replicated:FindFirstChild("YOUR_TOOL"):Clone()
Tool.Parent = Players:FindFirstChild(Target).Backpack
end)
Notice: you might need to modify the scripts a bit.
The script is trying to find âBraised Beef Cheek | Fanta | Cookie Doughâ but the toolâs name is âBraised Beef Cheek | Cookie Dough | Fantaâ. They have different names.