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

Filtering Enabled help with Leveling Up? [SOLVED]

So im trying to get the client to tell the server to level up the player when the player's exp is 25 times the players level but so far it isnt working

--Client Side(located in starter gui)
function levelup(player)
if (game.Players.LocalPlayer.ldr.Exp >= game.Players.LocalPlayer.ldr.Level*25) then
	local levelup = game.ReplicatedStorage.RemoteEvents.lvlevent:InvokeServer()
end
end
--Server Side(located in server script storage

function levelup(player)
local exp = player.ldr.Exp
if (exp.Value ) then
math.floor(player.ldr.Level.Value*25)
math.floor(exp.Value - player.ldr.Level.Value*25)
	return true
end
return false
end
game.ReplicatedStorage.RemoteEvents.lvlevent.OnServerEvent = levelup

1 comment

0

line 12. OnServerEvent should be OnServerInvoke

1 answer

ClientSide

local exp = game.Players.LocalPlayer.ldr.Exp
local level = game.Players.LocalPlayer.ldr.Level
exp.Changed:connect(function()
	if exp.Value >= level.Value * 25 then
		game.ReplicatedStorage.RemoteEvents.lvlevent:FireServer()
	end
end)

ServerSide

function levelup(player)
	local change = true
	while change do
		change = false
		if player.ldr.Exp.Value >= player.ldr.level.Value * 25 then
			player.ldr.Exp.Value = player.ldr.Exp.Value - player.ldr.level.Value * 25
			player.ldr.level.Value = player.ldr.level.Value + 1
			change = true
		end
	end
end
game.ReplicatedStorage.RemoteEvents.lvlevent.OnServerEvent = levelup

2 comments

0

so i did my server side correctly?

0

If youre using remote event and not function then OnServerEvent = levelup should be at the top of the script and should not be "=" but instead game.ReplicatedStorage.RemoteEvents.lvlevent.OnServerEvent:Connect(function(player) then your code then end)

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