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

I'm trying to make this script give me 2nd Level at 70XP, but it can't find the XP?

I'm not sure what I did wrong I looked over the code and it says that it can't find the XP in the stats which I'm confused If anyone could help me I would thankful Here's the script

local plr = game.Players.LocalPlayer
local Stats = game.Players.LocalPlayer:WaitForChild("Stats")
local XP = Stats:FindFirstChild("XP")
if XP.Value > 70 then
	plr.leaderstats.Level.Value = 2
end

1 comment

0

is it named XP?

1 answer

You have to wait for XP not FindFirstChild... another issue is that you cannot change values localside (meaning everyone can see it as serversided). Changing values with a localscript on does localside so others will not see your level / scripts wont be able to see the hacked level! Instead use below.

In LocalScript

local plr = game.Players.LocalPlayer
local Stats = game.Players.LocalPlayer:WaitForChild("Stats")
local XP = Stats:WaitForChild("XP")
if XP.Value > 70 then
    game.ReplicatedStorage:WaitForChild("LevelUpEvent"):FireServer(12345) --Fires the leveling up event!. Change 12345 to the security ID in the serverscript!
end

In ServerScript

local event = Instance.new("RemoteEvent") --Creates the LevelUpEvent
event.Name = "LevelUpEvent" --Changes the name to "LevelUpEvent"
event.Parent = game.ReplicatedStorage --Sets the parent of the event to ReplicatedStorage

local SecurityIDD = "12345" --I'd recommend to change this every week or so. and change it currently, This is so people cannot attempt to cheat ROBLOX and get free levels. This can also be as long and as complicated as you want!

event.OnServerEvent:Connect(function(player, SecurityID) --Detects localscript "FireServer()"
	if SecurityID == SecurityIDD then --Checks security ID
		player:WaitForChild("leaderstats"):WaitForChild("Level").Value = player:WaitForChild("leaderstats"):WaitForChild("Level").Value + 1 -- add a level to the player
		player:WaitForChild("Stats"):WaitForChild("XP").Value = 0 --Reset the XP back to zero.
	end
end)

1 comment

0

I will accept the answer, but I ment that the xp doesn't reset to 0 and where do I put local script and serverscript?

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