Hello!
I have recently been getting help from some very kind developers to help fix some errors in my system. However, i have this really annoying feature where it gets the items from a different script. Can anyone help me get the items from the replicated storage module script?
Replicated Module: Where i want to be able to customize the items
local MerchantHandler = {}
local Player = game.Players.LocalPlayer
local LeaderstatsFolder = Player:WaitForChild("leaderstats")
local BoostsFolder = Player:WaitForChild("Boosts")
MerchantHandler.PotionPurchaseCooldown = 3600 -- (3600 = 1 Hour), (86400 = 1 Day)
MerchantHandler.Items = {
---/// CHANGE TITLE TO POTION NAME
["Potion1"] = {Potion = BoostsFolder["Gem Potion"], Time = 30, Image = "rbxassetid://15434984615", Title = "Gem Potion", MaxPurchase = 1, Purchased = 0, Price = 12, Currency = LeaderstatsFolder:WaitForChild("Taps")},
["Potion2"] = {Potion = BoostsFolder["Super Lucky"], Time = 60, Image = "rbxassetid://15434984615", Title = "Super Luck Potion", MaxPurchase = 2, Purchased = 0, Price = 24, Currency = LeaderstatsFolder:WaitForChild("Taps")},
["Potion3"] = {Potion = BoostsFolder["Extra Lucky"], Time = 90, Image = "rbxassetid://15434984615", Title = "Luck Potion", MaxPurchase = 3, Purchased = 0, Price = 36, Currency = LeaderstatsFolder:WaitForChild("Taps")},
}
function MerchantHandler.CreatePotionPurchaseFrame(name)
local Template = script.Parent:WaitForChild("Potion1"):Clone()
local gui = Player.PlayerGui:WaitForChild("Main"):WaitForChild("TravellingMerchant")
Template.Name = MerchantHandler.Items[name].Title
Template.Icon.Image = MerchantHandler.Items[name].Image
Template.PotionName.Text = MerchantHandler.Items[name].Title
Template.Purchased.Text = MerchantHandler.Items[name].Purchased.."/"..MerchantHandler.Items[name].MaxPurchase
Template.PriceLabel.Text = MerchantHandler.Items[name].Price.." "..MerchantHandler.Items[name].Currency.Name
Template.Parent = gui:WaitForChild("Main"):WaitForChild("Container")
Template.BuyButton.Button.MouseButton1Click:Connect(function()
game.ReplicatedStorage:WaitForChild("Merchant").PotionPurchase:FireServer(name)
end)
end
return MerchantHandler
Server Module: Thing i want removed
local MerchantHandler = {}
function MerchantHandler.GetItems(player)
local LeaderstatsFolder = player:WaitForChild("leaderstats")
local BoostsFolder = player:WaitForChild("Boosts")
local Items = {
["Potion1"] = {Potion = BoostsFolder["Gem Potion"].Value, Time = 30, Image = "rbxassetid://15434984615", Title = "Gem Potion", MaxPurchase = 1, Purchased = 0, Price = 12, Currency = LeaderstatsFolder:WaitForChild("Taps")},
["Potion2"] = {Potion = BoostsFolder["Super Lucky"].Value, Time = 60, Image = "rbxassetid://15434984615", Title = "Super Luck Potion", MaxPurchase = 2, Purchased = 0, Price = 24, Currency = LeaderstatsFolder:WaitForChild("Taps")},
["Potion3"] = {Potion = BoostsFolder["Extra Lucky"].Value, Time = 90, Image = "rbxassetid://15434984615", Title = "Luck Potion", MaxPurchase = 3, Purchased = 0, Price = 36, Currency = LeaderstatsFolder:WaitForChild("Taps")},
}
return Items
end
return MerchantHandler
Server Script
local mod = require(game:GetService("ServerStorage"):FindFirstChild("MerchantItems"))
local Remote = game:GetService("ReplicatedStorage"):FindFirstChild("Merchant").PotionPurchase
Remote.OnServerEvent:Connect(function(Player, purchaseThis)
local Items = mod.GetItems(Player) -- Use mod.Items directly
local info = Items[purchaseThis]
local statsValue = Player:WaitForChild("Boosts"):FindFirstChild(info.Title)
if not statsValue or not info then warn("No Boost or info") return end
local price = info.Price
local currency = info.Currency
if currency.Value >= price then
currency.Value -= price
statsValue.Value += info.Time
end
end)
Thanks!