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

My crafting gui can't give me an item (all two is local script) how to fix it?

this is for make the weapon axe(a tool)

local Player = game.Players.LocalPlayer
local ls = Player:WaitForChild("hiddenstats")
local Scrap = ls:FindFirstChild("Scrap")
local Rubber = ls:FindFirstChild("Rubber")
local Plank = ls:FindFirstChild("Plank")
local Tool = game.ReplicatedStorage.Axe

script.Parent.MouseButton1Click:Connect(function()
	if Scrap.Value > 3 then
		if Plank.Value > 5 then
			Scrap.Value = Scrap.Value - 3
			Plank.Value = Plank.Value - 5
			Tool:Clone()
			Tool.Parent = Player.Backpack
		end
	end
end)

this is for warn the player he or she have no items

local Player = game.Players.LocalPlayer
local ls = Player:WaitForChild("hiddenstats")
local Scrap = ls:FindFirstChild("Scrap")
local Rubber = ls:FindFirstChild("Rubber")
local Plank = ls:FindFirstChild("Plank")

script.Parent.MouseButton1Click:Connect(function()
	if Scrap.Value < 3 then
		if Plank.Value < 5 then
			script.Parent.Text = "Not Enough Materials!"
			wait(1)
			script.Parent.Text = "Craft"
		end
	end
end)

1 comment

0

In class right now, will try to help later. Does anything show in the output?

1 answer

✓ Accepted answer

For the first script, lines 13 and 14 are the problem. You're cloning the tool, but it's not making it to the player's backpack because you didn't define the cloned tool.

local clone = Tool:Clone()
clone.Parent = Player.Backpack

I assume that the price required is 3 scrap and 5 planks, so you just need to include an equal sign after the > in each if statement.

For the second script, you might consider combining the if statements so that if the player doesn't have enough scrap or enough plank, they can't buy it. Currently, your script only warns the player if they don't have enough of both.

if Scrap.Value < 3 or Plank.Value < 5 then
	--Not enough materials
end

1 comment

0

He did define the tool. To clone the tool he needs to fire a event so the server knows since he is using localscripts

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