I'm working on a shop that uses a remote event. But I can't seem to figure out how to make the value change to what it needs to be instead of being the one that was set in studio.
-- References
local GameItems = ReplicatedStorage.GameItems
--------------------------------------------------------------------
ReplicatedStorage.RemoteEventBuy.OnServerEvent:Connect(function(plr, Selected, SelectedPrice)
local leaderstats = plr:WaitForChild("leaderstats")
local Gold = leaderstats:WaitForChild("Gold")
local Backpack = plr:WaitForChild("Backpack")
local StarterGear = plr:WaitForChild("StarterGear")
print(Gold.Value)
print(SelectedPrice.Value) <-- This prints out 0 because thats what it is set to in studio.
print(Selected.Value) <-- This prints blank because thats what it is set to in studio.
if Gold.Value >= SelectedPrice.Value then
Gold.Value = Gold.Value - SelectedPrice.Value
local NewItemBackpack = GameItems[Selected.Value]:Clone()
local NewItemStarterGear = GameItems[Selected.Value]:Clone()
NewItemBackpack.Parent = Backpack
NewItemStarterGear.Parent = StarterGear
print("Succesfully sold!")
else
warn("This wont work")
end
end)

1 comment
I forgot to mention on how the selected value is set. You set it by pressing on the option that you want and then you press buy (My bad!) . But I'll try figuring it out on how you said it here.