Object Value Not Changing

So Im working on a GUI that has a button that changes an Object value. But whenever the button is pressed nothing happens to the Object Value.

Here is my code

local item = script.Parent.Parent.Parent.Parent:WaitForChild("Primary")
script.Parent.MouseButton1Down:Connect(function()
	script.Parent.Parent.Parent.Parent.VCMain.pri.Text = "AK47"
	item = game.ServerStorage:WaitForChild("AK47")
	script.Parent.Parent.Visible = false
end)

Thank you in advance!

1 Like

You just forgot to add .Value when you were setting it to the AK.

item.Value = game.ServerStorage:WaitForChild("AK47")

3 Likes

Is that a local script tho?
If so, you can not access Server Storage from a local script

[Adding to what @fungi3432 has said]

1 Like

It was a local script! I just changed it, but it still doesn’t work even with the .Value at the end. It just makes it so it tries finding an object called value in the AK47 which there is not one.

I don’t really understand what you mean by this. Could you please explain again what this new issue is?

Basically, its trying to find and object called value that is a parent of the AK47,
sorry for my poor wording!

1 Like

Where is the script that changes the object value running in?
Remember that if the script is in any storage service, it won’t work. I most recommend that the script is in ServerScriptService.

Its running inside a GUI button, in which it changes a value within the player, would I have to make a new script in ServerScriptService that detects what button the player presses and changes the value accordingly?