Hello, I have a problem in the script, when I buy a class, I do not buy it, I used to have a class in the player, now I did it for leaderstats and it is not possible to buy, look in the script, I just do not understand what the problem is here
local alertClients = game.ReplicatedStorage.ServerMessage
local MarketPlaceService = game:GetService("MarketplaceService")
local gamepassId = 257905319
local strengthPass = 257904902
local endPass = 257904475
local mults = require(game.ServerStorage.classMults)
local function ownsgamepass(userId, gamepassId)
local ownsGamepass
local s,res = pcall(function()
ownsGamepass = MarketPlaceService:UserOwnsGamePassAsync(userId, gamepassId)
end)
return ownsGamepass
end
event.OnServerEvent:Connect(function(player, stat, val, op)
local value = val -- to not alter original value
local owns = ownsgamepass(player.UserId, gamepassId)
if (stat == "Strength" and ownsgamepass(player.UserId, strengthPass))
or (stat == "Endurance" and ownsgamepass(player.UserId, endPass)) then
value *= 2
end
if stat.ClassName ~= "StringValue" and type(value)~='number' then
warn("value is not number. the value is", value, "the stat is", stat)
end
if op == "+" then
if player.Character.SafeZone.Start.Value == true then
player:WaitForChild(stat).Value += value * value
end
if owns then
player:WaitForChild(stat).Value += value * 2
else
player:WaitForChild(stat).Value += value
end
elseif op == "set" then
if typeof(value)=="number" and owns and not stat:match("Multi") then
--print(value)
player:WaitForChild(stat).Value = value * 2
else
player:WaitForChild(stat).Value = value
end
if val:match("Class") then
alertClients:FireAllClients(player.Name.." has ranked up to "..value.."!") -- doesn't need player to send to
end
end
end)