Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

attempt to index upvalue?

So simple shop GUI and this is the purchase button. Here is what it says when I try to click purchase: Players.Player1.PlayerGui.Shop.infBack.Buy.LocalScript:8: attempt to index upvalue 'wep' (a nil value)

So yeah and here is the code:

local but = script.Parent
local gun = but.Parent.Weapon.Value
local wep = game.ReplicatedStorage.Weps:FindFirstChild(gun)
local player = game.Players.LocalPlayer
local pack = player.Backpack

but.MouseButton1Click:connect(function()
	wep:Clone(pack)
end)

Weapon is a StringValue. I tried changing the variable gun to just but.Parent.Weapon and no .Value but that also does not work.

Now i'm certain that the gun is in the folder(weps) in replicated storage I could see it when I clicked purchase so i'm not sure what i'm doing wrong here. Any help is appreciated :)

2 comments

1

Try changing line 8 = wep:Clone().Parent = pack

0

That won't fix the problem as 'wep' is nil. Though it does fix another problem.

1 answer

There are two possibilities here, either line 3 with isn't getting a string as the first argument, or the object doesn't exist under than name

This discussion is preserved as it was. New answers, comments, and votes are closed.