Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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)
0
In class right now, will try to help later. Does anything show in the output? Nitrolux200 62 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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
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 334901766 25 — 3y
Ad

Answer this question