Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

HELP! My crafting gui won't work?

This is on a local script

I tested the script and when I tried to craft, It worked...... but it didn't give me what I crafted.

Please help me!

---- Load Stuff ----

local us = game:GetService("UserInputService")
local crafts = game.ServerStorage:WaitForChild("Craft")
local p = game.Players.LocalPlayer

print('Loaded stuff! O3O')

---- Crafting ----

function Add(o)
	game.Players.LocalPlayer.PlayerGui.GUIC.Craft.Craft.Text = game.Players.LocalPlayer.PlayerGui.GUIC.Craft.Craft.Text .. o.Name .. ", "
	o:remove()
end

function sel(obj)
	if obj.Locked ~= true then
		Add(obj)
	end
end

local m = game.Players.LocalPlayer:GetMouse()

m.Button1Down:connect(function()
	if m.Target ~= nil then
	sel(m.Target)
	end
end)

m.KeyDown:connect(function(key)
	if key == "f" then
		for _,c in pairs(crafts:GetChildren()) do
			if c:FindFirstChild("Recipe").Value == p.PlayerGui.GUIC.Craft.Craft.Text then
				if c.ClassName == "Tool" then
					c:Clone().Parent = p.Backpack
					p.PlayerGui.GUIC.Craft.Craft.Text = ""
					return
				else
					for _,cc in pairs(c:GetChildren()) do
						if cc.ClassName == "HopperBin" then
							cc:Clone().Parent = p.Backpack
							p.PlayerGui.GUIC.Craft.Craft.Text = ""
							return
						end
					end
				end
			else
				p.PlayerGui.GUIC.Craft.Craft.Text = ""
				return
			end
			
		end
	end
end)

---- Inventory ----


Update: Checking the Recipe values didn't work. They are all perfect but it's still not working. I recorded a video of the error. Take a look

Update: I'm going insane with my game broken. I'm starting to consider quitting on making a survival game. I'd make another game based on a game I played in 5th grade ._.

3 comments

0

What is this used for? Like the game? Just wondering. looks interesting because most games avoid crafting.

0

@JohnTUnderwood I am using this for a survival game (similar to survival 404)

0

Oh, cool.

1 answer

the code looks good, check the game.ServerStorage.Craft folder and verify that all resipies are not empty strings "" and that what you are trying to make is typed correctly. Add print statements to print the gui label and compare side by side with the target resipie to ensure not a single capital or space is out of place.

1 comment

0

I tried this but my recipe's are perfect. Got any other suggestions?

This discussion is preserved as it was. New answers, comments, and votes are closed.