Why is this not working?

so i am making a game and i want to make it where when the player clicks a gui they get an item, so why is this not working here is a pic of my script:

Where is your local script placed? Also, you cannot access ServerStorage from the client.

Try to put the tool into the ReplicatedStorage and change the script into this:

local tool = game.ReplicatedStorage["YELLOW SWORD"]
local klone = tool:Clone()
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
   if klone.Parent ~= plr.Backpack then
    klone.Parent = plr.Backpack
    end
end)

This isn’t a problem with the script you showed us I think. There are no commands appear to make an Http Request in this script so it’s probably a different script

Actually, looking at the error code it seems this error is happening on line 10 of your server script: time-save script. Can we see the code for that script instead? Also, you can click the red error code and it will take you to the line that caused the error. Last thing, for future reference you can place your code in-between three backticks like this

```

– your code would go in-between the two sets of backticks

```

This would end up producing an effect like this:

local examplecodevariable = "This makes it easier for others to edit and read your code"
1 Like

you cant access serverstorage from a localscript so follow @CCCelestina

2 Likes
local tool = game.ServerStorage["YELLOW SWORD"]
local klone = tool:Clone()
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
   if klone.Parent ~= plr.Backpack then
    klone.Parent = plr.Backpack
   end
end)

i just noticed that you using clickdetector so here

Actually, don’t you need to say:

script.Parent.ClickDetecter.MouseButton1Click

Because, you know it’s a GUI Button.

hes using clickdetector not gui

A couple things

  • Your scripts are “Uncommitted”, which will not update the code even if you start the game

  • If you’re referencing this inside the Part, you cannot use LocalScripts inside the workspace

    • If you’re not & referencing it inside the Player’s Gui, Yeah can’t do that either GuiButtons don’t have ClickDetectors (Highly doubt it’s that though)
  • I’m questioning these lines here, what purpose does it serve if you’re checking the tool in the Backpack just to parent it again?

image

  • No need to reference the Player parameter in the ClickDetector, unless if this is a Server Script

Well, in that case, it’s MouseClick then.