I did but it came up with that error.
When i click the gui this is what comes up
EDIT: Sorry for late responses btw, been playing roblox with some friends but im done now lol
I did but it came up with that error.
When i click the gui this is what comes up
EDIT: Sorry for late responses btw, been playing roblox with some friends but im done now lol
Yes that would happen but what is the output if you add in
print(Items)
nope in the other server script
no in the server script those are module scripts
ok so it is working all that is wrong is the purchaseThis parameter. Try printing that out
It prints out the same thing as the previous one
Ok so when firing the server don’t include the player parameter it automatically gets sent through
Those are fine just leave that there it only when firing you only send 1 parameter
Let’s see all your scripts now
ServerStorage:
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")},
}
print(Items)
return Items
end
return MerchantHandler
Replicated
local MerchantHandler = {}
local Player = game:GetService("Players").LocalPlayer
local LeaderstatsFolder = Player:WaitForChild("leaderstats")
local BoostsFolder = Player:WaitForChild("Boosts")
MerchantHandler.PotionPurchaseCooldown = 3600 -- (3600 = 1 Hour), (86400 = 1 Day)
MerchantHandler.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")},
}
function MerchantHandler.CreatePotionPurchaseFrame(name)
local Template = script.Parent:WaitForChild("Potion1"):Clone()
local gui = Player.PlayerGui:WaitForChild("Main"):WaitForChild("PotionMerchant")
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(MerchantHandler.Items[name])
end)
end
return MerchantHandler
Serverscript
local mod = require(game:GetService("ServerStorage").MerchantHandler)
local Remote = game:GetService("ReplicatedStorage"):FindFirstChild("Merchant").PotionPurchase
Remote.OnServerEvent:Connect(function(purchaseThis, Player)
local Items = mod.GetItems(Player)
local statsValue = Player:WaitForChild("Boosts"):FindFirstChild(purchaseThis)
local info = Items[purchaseThis]
if not statsValue or not info then warn("No Boost or info") end
local price = info[purchaseThis].Price
local currency = Player:WaitForChild("leaderstats")[info[purchaseThis].Currency.Value]
if currency >= price then
currency -= price
statsValue.Value += info[purchaseThis].Time
end
end)
Don’t switch them round… Player will always be the first received parameter on a server event. Then it is all the other parameters you passed through
Made another post which is clearer. try post on there if you can lol
Ok well this script should work
local mod = require(game:GetService("ServerStorage").MerchantHandler)
local Remote = game:GetService("ReplicatedStorage"):FindFirstChild("Merchant").PotionPurchase
Remote.OnServerEvent:Connect(function(Player,purchaseThis)
local Items = mod.GetItems(Player)
local statsValue = Player:WaitForChild("Boosts"):FindFirstChild(purchaseThis)
local info = Items[purchaseThis]
if not statsValue or not info then warn("No Boost or info") end
local price = info[purchaseThis].Price
local currency = Player:WaitForChild("leaderstats")[info[purchaseThis].Currency.Value]
if currency >= price then
currency -= price
statsValue.Value += info[purchaseThis].Time
end
end)
2 things:
Sorry can’t talk for any longer. But you could try just putting all the info in the first module script but leave out the bit where you try and get the values then when you need the table you can check in that script for the value of it using the name