local classes = require(script.Parent.Classes)
local mps = game:GetService("MarketplaceService")
if classes.Economy == false then
script.Parent.Dialog.CheckIn.Economy:Destroy()
end
if classes.PremiumEconomy == false then
script.Parent.Dialog.CheckIn.PremiumEconomy:Destroy()
end
if classes.Business == false then
script.Parent.Dialog.CheckIn.Business:Destroy()
end
if classes.Investor == false then
script.Parent.Dialog.CheckIn.Investor:Destroy()
end
script.Parent.CheckIn.OnServerEvent:Connect(function(plr,class)
if classes[class] == 0 then
game:GetService("ServerStorage")(class.Name):Clone().Parent = plr.Backpack
else
if mps:UserOwnsGamePassAsync(plr.UserId,classes[class]) then
game:GetService("ServerStorage")(class):Clone().Parent = plr.Backpack
else
mps:PromptGamePassPurchase(plr,classes[class])
end
end
end)
Classes (Module Script)
-- If a class is free, set it to 0. If the class is paid set it to the gamepass id. If you want to disable a class, set it to false.
local classes = {}
classes.Economy = 0
classes.PremiumEconomy = 0
classes.Business = 0
classes.Investor = 0
return classes
Localscript
local dialog = game.Workspace:WaitForChild("CheckIn NPC").Head.Dialog
dialog.DialogChoiceSelected:Connect(function(plr,choice)
if choice == dialog.Economy then
dialog.Parent.Parent.CheckIn:FireServer(game.Players.LocalPlayer,"Economy")
elseif choice == dialog.Business then
dialog.Parent.Parent.CheckIn:FireServer("Business")
elseif choice == dialog.Investor then
dialog.Parent.Parent.CheckIn:FireServer("Investor")
elseif choice == dialog.PECO then
dialog.Parent.Parent.CheckIn:FireServer("PremiumEconomy")
end
end)
In your LocalScript, you can change it and remove the game.Players.LocalPlayer because RemoteEvents automatically pass the player who fired the remote to the server.
local dialog = game.Workspace:WaitForChild("CheckIn NPC").Head.Dialog
dialog.DialogChoiceSelected:Connect(function(plr,choice)
if choice == dialog.Economy then
dialog.Parent.Parent.CheckIn:FireServer("Economy")
elseif choice == dialog.Business then
dialog.Parent.Parent.CheckIn:FireServer("Business")
elseif choice == dialog.Investor then
dialog.Parent.Parent.CheckIn:FireServer("Investor")
elseif choice == dialog.PECO then
dialog.Parent.Parent.CheckIn:FireServer("PremiumEconomy")
end
end)
you used wrong brackets, its [class] no (class), so you can try this:
local classes = require(script.Parent.Classes)
local mps = game:GetService("MarketplaceService")
if classes.Economy == false then
script.Parent.Dialog.CheckIn.Economy:Destroy()
end
if classes.PremiumEconomy == false then
script.Parent.Dialog.CheckIn.PremiumEconomy:Destroy()
end
if classes.Business == false then
script.Parent.Dialog.CheckIn.Business:Destroy()
end
if classes.Investor == false then
script.Parent.Dialog.CheckIn.Investor:Destroy()
end
script.Parent.CheckIn.OnServerEvent:Connect(function(plr,class)
if classes[class] == 0 then
game:GetService("ServerStorage")[class]:Clone().Parent = plr.Backpack
else
if mps:UserOwnsGamePassAsync(plr.UserId,classes[class]) then
game:GetService("ServerStorage")[class]:Clone().Parent = plr.Backpack
else
mps:PromptGamePassPurchase(plr,classes[class])
end
end
end)
it must be:
mps:UserOwnsGamePassAsync(userID,gamepassID)
and gamepassID cant be 0, so you can add more values in your module script like this:
-- If a class is free, set it to 0. If the class is paid set it to the gamepass id. If you want to disable a class, set it to false.
local classes = {}
classes.Economy = 0
classes.PremiumEconomy = 0
classes.Business = 0
classes.Investor = 0
classes.EconomyGamepass = 8426083
classes.PremiumEconomyGamepass = 234567
classes.BusinessGamepass = 345678
classes.InvestorGamepass = 456789
return classes
local classes = require(script.Parent.Classes)
local mps = game:GetService("MarketplaceService")
if classes.Economy == false then
script.Parent.Dialog.CheckIn.Economy:Destroy()
end
if classes.PremiumEconomy == false then
script.Parent.Dialog.CheckIn.PremiumEconomy:Destroy()
end
if classes.Business == false then
script.Parent.Dialog.CheckIn.Business:Destroy()
end
if classes.Investor == false then
script.Parent.Dialog.CheckIn.Investor:Destroy()
end
script.Parent.CheckIn.OnServerEvent:Connect(function(plr,class)
if classes[class] == 0 then
game:GetService("ServerStorage")[class]:Clone().Parent = plr.Backpack
else
print(plr,classes[class.."Gamepass"])
if mps:UserOwnsGamePassAsync(plr.UserId, classes[class.."Gamepass"]) then
game:GetService("ServerStorage")[class]:Clone().Parent = plr.Backpack
else
mps:PromptGamePassPurchase(plr,classes[class.."Gamepass"])
end
end
end)
My solution was incorrect, I thought class was an instance but it was actually a string, you use class.Name in an earlier line so I thought it was an instance.
And it should have errored because it’s still nil
I’m really confused. Btw you are way too inconsistent, sometimes you do (class) other times you do [class]. The 2 marketplace service calls, one uses plr.userid the other uses plr