IfI will correct the class then I can not use the power and the multiplier and If power only classes I can not
Stat not found for player: Lamino961 Stat: Class - Server - AddStatScript:23
Guys, I really want to fix the bug, I have no options on how to fix it, please help, is this still relevant
You can still research about your problem though, I explained to you how you can make it work.
I know how to fix it, the problem is different
My classes are in the leaderstats, but total power and strength and endurance are in the player
I make new script
local MarketPlaceService = game:GetService("MarketplaceService")
local event = game.ReplicatedStorage.AddStat
local alertClients = game.ReplicatedStorage.ServerMessage
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)
print(stat)
local value = val
local owns = ownsgamepass(player.UserId, gamepassId)
local playerStat = player: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
alertClients:FireAllClients(player.Name.." has ranked up to "..value.."!") -- Handle class purchase logic here
end
end
end)
It’s still relevant and I haven’t fixed it.
Help me fix this already please I really need it I haven’t been able to do it all day
Could you rephrase what the problem is that way Im all caught up
To summarize after piecing the previous replies, if you access the class you can’t buy the multiplier and if you access the multiplier you can’t access the class?
I suggest sending another param from the local script firing “AddStat” event to determine whether you want to modify a class or a stat. Optionally you can do
local playerstat = player:FindFirstChild(stat) or player.leaderstats:FindFirstChild(stat)
-- where before the or you’re looking for the stat and after the or you’re looking for a class
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.