Help to fix script

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)
6 Likes

help fix the problem i really need it

Didn’t you say you used to buy 2 classes at once before? Also I feel like the code you’ve provided feel unfinished.

1 Like

This is a different script it is responsible for statistics multiplication

And the other is buying a class

I’ll turn on the computer now, check if it works or not, write

Can you help with this script?

I’ll try to see the problem. Could try to explain it further? If you can it will help a lot, thank you. Like what is this script for again?

I buy a class I write in the output that the problem is here

This script is responsible for the boost I get and for the class too, you can almost say

Could you identify the code for the class just the portion. Thank you

I don’t know the would have known, I would have fixed it myself

I checked your script that you sent as a file form this is what I wanted, thank you, could you help me make it for my game?

Did you follow a tutorial? Because if you did you can try to look at the part where you wrote this code and fix it. If not I’ll try to see the problem.

let me give access to my game and see all the bug there

Do you agree or disagree? I’ll give you access

It is up to you. I was hoping I could work with someone on a game.

let me give you a link to skin ls write me a private message something