Local Script Error and Question

Hello,

First the question: Can a local script not find for example a folder in ServerStorage? Second the error is attempt to index nil with FindFirstChild

script:

local player = game.Players.LocalPlayer 
local backpack = player.Backpack 

local tool = game.GetService:(“ServerStorage”):FindFirstChild:(“Computers”):FindFirstChild:(“Slow Computer”) 
local c = tool:clone() 
script.Parent.MouseButton1Click:Connect(function() 
script.Parent.Visible = false 
script.Parent.Parent.Unequip.Visible = true 
backpack:FindFirstChildWhichIsA(“Tool”):Destroy() 
task.wait(1) 
c.Parent = backpack

this grabs the tool from the computer folder, deletes the current item in backpack and replaces it with the selected tool. Any help is highly appreciated.

ServerStorage does not replicate to the client, only the server can access ServerStorage.
You could use ReplicatedStorage which the client and server both can access.

1 Like

script needs to know if that computer exist

a local script can’t access ServerScriptService and ServerStorage.
the error says you’re trying to call FindFirstChild from nil. it could be because it’s a local script so local tool = game.GetService:(“ServerStorage”):FindFirstChild:(“Computers”) will return nil.

Everything that you see on the explorer while playtesting on the client side is accessible through your local scripts. You can see that ServerStorage and ServerScriptService become empty, which is why you can’t access them from a local script.

1 Like

So would this mean i would put a server script in the ui button?

You should get when the text button is clicked with a local script, then you could use a remote event.

1 Like

Hiya, also I noticed that when you did the ‘MouseButton1Click’ that part you forgot that you need to end the statement by doing

local player = game.Players.LocalPlayer 
local backpack = player.Backpack 

local tool = game.GetService:(“ServerStorage”):FindFirstChild:(“Computers”):FindFirstChild:(“Slow Computer”) 
local c = tool:clone() 
script.Parent.MouseButton1Click:Connect(function() 
	script.Parent.Visible = false 
	script.Parent.Parent.Unequip.Visible = true 
	backpack:FindFirstChildWhichIsA(“Tool”):Destroy() 
	task.wait(1) 
	c.Parent = backpack
end)

that was a forgotten thing when typing this on mobile. thanks anyway.

That’ll work well. Thank you ill let you know if this was my solution (i mean ill mark you as solution)