So I am trying to make a shop script which allows you to buy items and equip them later when they are already owned, the script works almost flawlessley…
Until you get to the part where the Bool Value does not change
I’ve tried putting “local unequipmode = false” outside the script, inside the “Owned” part, etc., etc., etc. however it just won’t work.
NOTE: the script comes out with absolutely no errors, and knows the Value’s instance in every part of the code
local replicatedStorage = game:GetService("ReplicatedStorage")
local Potions = game:GetService("ServerStorage"):WaitForChild("Potions")
replicatedStorage.Potions.GetImage.OnServerInvoke = function(player,item)
return Potions[item].TextureId
end
replicatedStorage.Potions.GetInfo.OnServerInvoke = function(player,item)
return Potions[item].Price.Value
end
replicatedStorage.Potions.GetOwnership.OnServerInvoke = function(player,item)
if player.ToolsSave:FindFirstChild(item) then
return true
end
end
replicatedStorage.Potions.Equip.OnServerInvoke = function(player,item)
if player.Backpack:FindFirstChild(item) then
return true
end
end
replicatedStorage.Potions.CheckSale.OnServerInvoke = function(player,item)
local unequipmode = false
-- If item is owned
if player.ToolsSave:FindFirstChild(item) then
-- Equipping
if unequipmode == false then
print ("Equipping")
unequipmode = true
local gear = Potions[item]:Clone()
gear.Parent = player.StarterGear
gear.Price:Destroy()
local gear = Potions[item]:Clone()
gear.Parent = player.Backpack
gear.Price:Destroy()
local ItemsSave = player.ToolsSave
local Value = ItemsSave[item]
Value = true -- ***THE PROBLEM (Doesn't change the value to true)***
return true
-- Unequipping
else
print ("Unequipping")
unequipmode = false
local gearSR = player.StarterGear:WaitForChild(item)
local gearBP = player.Backpack:WaitForChild(item)
gearSR:Destroy()
gearBP:Destroy()
local ItemsSave = player.ToolsSave
local Value = ItemsSave[item.Name]
Value = false
return true
end
-- If item isn't owned
else
local price = Potions[item].Price.Value
if player.leaderstats.Gold.Value >= price then
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - price
local ItemsSave = player.ToolsSave
local Value = Instance.new ("BoolValue", ItemsSave)
Value.Name = item
Value = false
return true
end
end
end