What do you want to achieve? Keep it simple and clear!fix the problem: when I write the path to leaderstats in the script where the class is bought, I can’t buy the multiplier, but when I write the path to the leaderstat multiplier, I can’t buy the classes
What is the issue? Include screenshots / videos When I write the path to leaderstats in the script where the class is purchased, I can’t buy the multiplier, and when I write in the multiplier to leaderstats path, I don’t buy classes help fix
What solutions have you tried so far? Did you look for solutions on the Developer Hub?no one has been able to solve
local event = game.ReplicatedStorage.AddStat
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)
event.OnServerEvent:Connect(function(player, stat, val, op) -- WHERE DID YOU ADD A variable FOR EVENT
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
Hey, I will try to help you! let me know If you get any errors!
local MarketPlaceService = game:GetService("MarketplaceService")
local event = --[[ your event here ]]
local gamepassId = 257905319
local strengthPass = 257904902
local endPass = 257904475
local function ownsgamepass(userId, gamepassId)
local ownsGamepass = false
local success, res = pcall(function()
ownsGamepass = MarketPlaceService:UserOwnsGamePassAsync(userId, gamepassId)
end)
return success and ownsGamepass
end
event.OnServerEvent:Connect(function(player, stat, val, op)
local value = val
local owns = ownsgamepass(player.UserId, gamepassId)
local playerStat = player.leaderstats:FindFirstChild(stat)
if not playerStat then
warn("Stat not found for player:", player.Name, "Stat:", stat)
return
end
if (stat == "Strength" and ownsgamepass(player.UserId, strengthPass))
or (stat == "Endurance" and ownsgamepass(player.UserId, endPass)) then
value *= 2
end
if op == "+" then
if player.Character and player.Character:FindFirstChild("SafeZone") and player.Character.SafeZone.Start.Value == true then
playerStat.Value += value
end
if owns then
playerStat.Value += value * 2
else
playerStat.Value += value
end
elseif op == "set" then
if typeof(value) == "number" and owns and not string.match(stat, "Multi") then
playerStat.Value = value * 2
else
playerStat.Value = value
end
if string.match(val, "Class") then
-- Handle class purchase logic here
end
end
end)