UI doesn't give the tool

Hello!
I’m working on crafting system, how is it supposed to work?
If I have tool “test”, after I click the button, it’s supposed to give me tool “test2”.
It doesn’t work.

Here’s the script:

local player = game:GetService(“Players”)
script.Parent.MouseButton1Click:Connect(function()
if player.Localplayer.Backpack[“test”] then
local tool = game.ServerStorage[“test2”]
local klone = tool:Clone()
klone = player.Localplayer.Backpack
end
end)

Explorer picture: image

Can someone help me?

you cant access server storage from client put the tool in replicated storage and access
unless with remote

Well first off, you set klone value to the backpack when I think you meant to parent it to the backpack

I changed script a little, but it still doesnt work

local player = game:GetService(“Players”)
script.Parent.MouseButton1Click:Connect(function()
if player.Localplayer.Backpack[“test”] == true then
local tool = game.ServerStorage[“test2”]
local klone = tool:Clone()
klone = player.Localplayer.Backpack
end
end)

change the serverstorage in script line

yes

Yes, I wish to put the tool into backpack

Also, you made localplayer the entire player folder and I dont know if giving tools in local scripts is a good idea for FE reasons.

To the replicated storage? Right?

1 Like

also unequip your equipment before clicking on the button

I changed it to this, but it still doesn’t work

local player = game:GetService(“Players”)
script.Parent.MouseButton1Click:Connect(function()
if game.Players.LocalPlayer.Backpack[“test”] == true then
local tool = game.ServerStorage[“test2”]
local klone = tool:Clone()
klone = game.Players.LocalPlayer.Backpack
end
end)

local players = game:GetService("Players")

script.Parent.MouseButton1Click:Connect(function()
    if players.LocalPlayer.Backpack:FindFirstChild("Test") then
        local tool = game.ReplicatedStorage:FindFirstChild("Test2"):Clone()
        tool.Parent = players.LocalPlayer.Backpack
    end
end)

Move the tool2 in ReplicatedStorage.

1 Like

@ [MaxximusPower]
as he stated parent the tool

serverstorage can’t be accessed without remote with local script?

If so, what do I do then, sir?

From when? That’s not true you can access it without a RemoteEvent

I thought it was called server storage because the client can’t use it

Put the tool inside ReplicatedStorage and change your code to this.

local Players = game:GetService('Players')
local ReplicatedStorage = game:GetService('Players')

script.Parent.MouseButton1Click:Connect(function()
if Players.LocalPlayer.Backpack:FindFirstChild('test') then
local clone = ReplicatedStorage['test2']:Clone()
clone.Parent = Players.LocalPlayer.Backpack
end
end)

Ah right it’s a LocalScript i forgot sorry :\

local player = game:GetService(“Players”)

script.Parent.MouseButton1Click:Connect(function()
    if game.Players.LocalPlayer.Backpack[“test”] == true then
        local tool = game.ReplicatedStorage[“test2”]
        local klone = tool:Clone()
        klone.Parent=game.Players.LocalPlayer.Backpack
    end
end)

you need to parent the clone