How would I make an item unlock if a player is on a certain stage?

I’m making an obby game with the stage value in leaderstats. I have a Gui where whenever you press a button, it equips a halo using AddAccessory, using a remote event due to AddAccessory being server only. So, how would I make it so a player can only equip the halos for the stage they are on and the ones below it?

you can keep count of the stage their on and onyl allow them to equip it if they are on the stages you choose

Well yes, that’s what I’m trying to achieve but I don’t know how I would go about doing it.

Hello Abnumality!

So to be secure, you would check the stage value over the server in a remote event. You could do something like this, but it’s quite heavy loaded. You would also have to put all your halos or accessories inside a folder called “Halos” as well with having a IntValue defining what level you want them to be to achieve that halo

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player,Halo)
local PlayerStats = Player.leaderstats.Stage.Value
local FindHalo = game.ReplicatedStorage.Halos:FindFirstChild(Halo)
if FindHalo ~= nil then
if  PlayerStats <= FindHalo.Level.Value then
-- I can have halo
end
end
end)

Hope this helps!

you could make a folder in replicated stroage and when a player spawns it gives creates a numbervalue with the name as the player name. when they complete a level you would add 1 to the value. check if the value is equals or is more than the levels

or that it works too tbh e ;ccccc

I’ll tell you if this works. Seems promising though, my halos are already stored in ReplicatedStorage.

Do you think this would function if I put it inside the equip button?

It would work fine, you would just have to do something like this

script.Parent.MouseButton1Click:Connect(function()
if game.Players.LocalPlayer.leaderstats.Stage.Value >= 5 then
-- fire remote event to summon the halo
end
end)

Alright, it actually worked perfectly!

1 Like

Please! Handle everything through Remotes this can be easily bypassed - Never trust the client!

This should be a quick fix, I can do that right now.

Make if statment example
If game.Workspace.StageValue. Value = (the stage to unlock the item)
Then game.Workspace.Gun.Parent = Player.BackBag

Im not sure if the code is backbag try to run the game and see by your self