XP System Bugged

I’m Having A Problom With My XP System, So When The Player Finishes A Obby They Earn XP But The Player Never Get’s XP

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local remoteEvent = ReplicatedStorage.Events.MadeToEnd
local sendtime = ReplicatedStorage.Events.SendTime
script.Parent.Touched:Connect(function(hit)
	
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	local Playing = plr.Playing

	Playing.Value = true and Playing.Value == true do 
	
		Playing.Value = false
		
		remoteEvent:FireClient(plr)
		local function gettime(player, data)
			print(player.Name .. " got " .. data)

			if data < 40 then
				plr.leaderstats.xp.Value = plr.leaderstats.xp.Value + (50 - data)
			else
				plr.leaderstats.xp.Value = plr.leaderstats.xp.Value + 21
			end

		end


sendtime.OnServerEvent:Connect(gettime)
	end
	
	hit.Parent:MoveTo(Vector3.new(0.5, 1.5, -352))
	
end)


1 Like

Where do you give the data to the Event?

Also there is no need to use

Playing.Value = true and Playing.Value == true do

Instead you can use an if statement:

if Playing.Value == true then Playing.Value = false

I suggest reading on Saving Data

1 Like