I am making an anti-cheat, and part of it is checking if the progress bar for the EXP progress in the level system is greater than 1,0,1,0.
I want this because the level system is controlled in the server. When you change the EXP to be greater than the MaxEXP for that level locally, it will just make the progress bar larger than 1,0,1,0. But it spits out this error
This is the code:
while true do
if player.PlayerGui:WaitForChild("MainGui"):WaitForChild("Menu"):WaitForChild("PlayerInfo"):WaitForChild("Level"):WaitForChild("ProgressBar").Size < UDim2.fromScale(1, 0) then
player:Kick("\n You were kicked by Robo-AntiCheat: \n You attempted to change your EXP locally. \n\n You are not banned, so you are able to rejoin the experience.")
end
wait(5)
end
Error is in the if statement.
I have tried using UDim2.fromScale(1, 0) and Size.X = UDim.new(1) but neither worked.
I’ve also tried using Size.X < 1 and it returns this error:
You can’t compare 2 UDim2 values, but you can compare their X & Y sizes I believe
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local MainUI = PlayerGui:WaitForChild("Menu")
local PlayerInfo = MainUI:WaitForChild("Level")
local ProgressBar = PlayerInfo:WaitForChild("ProgressBar")
ProgressBar:GetPropertyChangedSignal("Size"):Connect(function()
if ProgressBar.Size.X.Scale < 1 then --I forgot how the hierarchy went for these properties
Player:Kick("\n You were kicked by Robo-AntiCheat: \n You attempted to change your EXP locally. \n\n You are not banned, so you are able to rejoin the experience.")
end
end)
Also, I’d personally wouldn’t do this on the client’s side because even though it may look good, exploiters can easily just remove that LocalScript with no problem whatsoever as they’re able to see anything that’s local-wise to them (LocalScripts, ReplicatedStorage, etc)
I’ve tried this already. Sorry I didn’t mention it in the post! I forgot to lol.
But, when I tried it before, and still now, it gives me this error
I forgot the order of the properties of UI Objects
I don’t have a good knowledge on where the UI properties are, so there was a chance that it didn’t work
Could you try again? I re-edited the script, so I think it should work this time (Unless if you have some other script that’s preventing it from firing)
The event fires, but it gives me the same error because it is running the same code as when it loaded the game.
But, I can’t run it server side because it would kick the player instantly as the frame changes size, even if it is less than 1.001 in size on the X access.
Also, the Anti-Cheat is set up to as where if the anti-cheat script is deleted, a second local script kicks the player, but if both are deleted, a server script from ServerScriptService kicks them. So that problem was solved before you mentioned that.
Unfortunate thing is I don’t know my way around with checking size properties in UI either, but hopefully I’ll find a way soon.
I recommend not making it detect if the size is more than 1, but rather 1.01 . This is because even if it shows “1” on your screen, in reality it might be 1.00108028408. Then it’ll kick the player unfairly
Do
if bar.Size.X.Scale >= 1.01 or bar.Size.X.Offset >= 1.01 then
--Kick the player
end
That’s weird though, cause Scale should be equivalent to a Number, unless if you’re putting the LocalScript in a different position, such as per se StarterPlayerScripts
UI Objects should have other smaller properties:
Size (Main one, UDim2 value)
X/Y (The X & Y Sizes of the UDim2)
Scale/Offset (The Scale & Offset Numbers of the UDim2)
I’d just double check to see what print(typeof(ProgressBar.Size.X.Scale)) & print(typeof(ProgressBar.Size.X)) gives you