Still have questions? Join our Discord server and get real time help.
Log in to vote

attempt to index upvalue?

Asked by 4 years ago

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


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 :)

Try changing line 8 = wep:Clone().Parent = pack User#11440 109 — 4y
That won't fix the problem as 'wep' is nil. Though it does fix another problem. Link150 1327 — 4y

1 answer

Log in to vote
Answered by 4 years ago

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


Answer this question