I recently came up with troubles trying to change an IntValue in one of my GUI's to be equal to a shirt ID. here is the script:
local vlu = game.StarterGui.ScreenGui.Shop.ScrollingFrame.Frame.ImageButton.ID.Value script.Parent.ClickDetector.MouseClick:connect(function() vlu = 912196966 end)
And my GUI script:
local itemID = script.Parent.ID.Value local player = game.Players.LocalPlayer script.Parent.MouseButton1Down:connect(function() game:GetService("MarketplaceService"):PromptPurchase(player, itemID) end)
For some odd reason, it does not work, could anyone tell me why? Thanks, Y.C.
Very common mistake. You're setting the variable to the value, not the object itself. So when you're changing it, it changes the variable but not the actual value itself. Think of it this way;
local test = workspace.IntValue.Value -- This sets the *variable* to the IntValue's Value. test = 10 -- This changes the variable, not the value itself. This is a very common mistake. local test2 = workspace.IntValue -- This targets the IntValue itself. test2.Value = 10 -- This will target the IntValue's Value, allowing you to change it.
TL;DR: Don't set a variable to .Value
. You edit the .Value
later on.
(also what Denny said, but too lazy to quote him.)
You need to add 'rbxassetid://' before the number. Numbers only won't work.
Line 3 would be something like this :
vlu = 'rbxassetid://912196966'