local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Tools = ReplicatedStorage:WaitForChild("Tools")
local CraftTool = ReplicatedStorage:WaitForChild("CraftTool")
local craftingInfo = require(ReplicatedStorage:WaitForChild("CraftingInfo"))
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CraftTool = ReplicatedStorage:WaitForChild("CraftTool")
local CraftingFrame = script.Parent
for i, button in pairs(CraftingFrame:GetChildren()) do
if button:IsA("TextButton") then
button.MouseButton1Up:Connect(function()
CraftTool:InvokeServer(button.Name)
print("print1")
end)
end
end
This code is under StarterGui.ScreenGui.Frame.LocalScript
The remote function referenced is under ReplicatedStorage
If it’s relevant, here is the received code:
CraftTool.OnServerInvoke = function(player, toolName)
local leaderstats = player.leaderstats
local crafted = false
for i, v in pairs(craftingInfo[toolName]) do
local material = leaderstats:FindFirstChild(i)
print("pleaseprint")
if material then
print("print2")
print1 and pleaseprint prints but not print2
Edited after narrowing problem down to for loop instead of invoke.
Does it work if you use ``if leaderstats:FindFirstChild(i) then? If it doesn't put an else on the if material then` and tell it to print every child of leaderstats.
Example:
if material then
print("print2")
else
for _, i in pairs(leaderstats:GetChildren()) do
print(i)
end
what are i and v in your for loop? try outputting both
did you make sure that FindFirstChild should be using i rather than v? and did you make sure whatever i is matches the name of something in leaderstats?
because it uses pairs(), the first isnt necessarily a number
it would be a string in { color = "red" } @UltraConstructor6 didnt reveal what’s inside craftingInfo though, so we can’t tell from here