Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Leaderboard: Level can go over max level?

I'm making where when a player goes over the level limit, it stops them at the max level you can be. I'm getting no errors whatsoever though, and the script won't work. Help?

--LOCAL SCRIPT--
local RS = game:GetService("ReplicatedStorage")
local remotef = RS.RemoteFunctions:WaitForChild("MaxyAssist")

local MV = remotef:InvokeServer(6000)
if game.Players.LocalPlayer.leaderstats.Level.Value >= (MV) then
	game.Players.LocalPlayer.leaderstats.Level.Value = (MV)
--SERVER SCRIPT--
function lV (player,levelMax)
	return levelMax
	end
	
	game.ReplicatedStorage:WaitForChild("RemoteFunctions").MaxyAssist.OnServerInvoke = lV

2 comments

0

If you're using a LocalScript, why are you using OnServerInvoke? Also your script gives the client too much power.

0

where is the part where it's supposed to prevent going above max level? I don't see any sort of restriction

1 answer

This should work.

--[[
	Normal script inside workspace
--]]
game.Players.PlayerAdded:Connect(funtion(plr) -- You can use something else instead of "plr".
	locals stats = instance.new("Model", plr) -- Change "stats" to whatever you want.
	stats.Name = "leaderstats" -- Do not change this except the "stats" part if you changed it up.
	
	local lvl = instance.new("IntValue", stats) -- Change "lvl" to anything.
	lvl.Name = "Level"
	lvl.Value = 1 -- This is the starting level, change it to anything you want.

	if lvl.Value > 6000 then
		lvl.Value = 6000
	end
end)

4 comments

0

This is also the most known way to make leaderstats and max stats.

0

Actually my script works, but it's really delayed.

0

The if statement is only going to run one time, you need to connect it to the Changed event

0

Fixed the delay in a different way, but thanks for trying to help. :)

This discussion is preserved as it was. New answers, comments, and votes are closed.