|
| 06 Jan 2017 08:59 AM |
I made a script that should protect players data from hackers. when a hacker tries to change their leaderstats the script should prevent that by resetting the stat to it's old value. but it keeps trowing errors like, table insert table expected, value is nil and it also trows a error by the table remove.
function StatusChanged(status, value, player) local changedstatus = CurrentStatus[player][status.Name][value] if status > changedstatus + MaxStatusChange or status < changedstatus - MaxStatusChange then status = changedstatus print(player.." tried to hack his/her status!") end end
function PlayerAdded(player) local playerdata = {} if EnableSafeStatus == true then wait(0.05) playerdata = {[player.Name] = {}} if player:FindFirstChild(StatusName) ~= nil then for a, b in ipairs(player[StatusName]:GetChildren()) do if b.ClassName == "IntValue" or b.ClassName == "NumberValue" then local status = {[b.Name] = b.Value} table.insert(playerdata[1], status[1]) end end end end playerdata = {} --Get rid of data we don't need anymore. end function PlayerRemoved(player) table.remove(CurrentStatus, player.Name) end ----------------------------------------------- game.Players.ChildAdded:connect(RemovePlayer) game.Workspace.ChildAdded:connect(RemoveTrash) game.Lighting.ChildAdded:connect(RemoveTrash) game.StarterGui.ChildAdded:connect(RemoveTrash)
game.Players.ChildAdded:connect(PlayerAdded) game.Players.ChildRemoved:connect(PlayerRemoved) ----------------------------------------------- --Advanced------------------------------------- for a, b in ipairs(game.Workspace:GetChildren()) do b.ChildAdded:connect(RemoveTrash) end for a, b in ipairs(game.Lighting:GetChildren()) do b.ChildAdded:connect(RemoveTrash()) end
for a, b in ipairs(game.Players:GetChildren()) do if b:FindFirstChild(StatusName) ~= nil then for a, b in ipairs(b[StatusName]:GetChildren()) do b.Changed:connect(function() StatusChanged(b, b.Value, b.Parent.Parent.Name) end) end end end
it's a anti hack system i worked for hours on. it should work perfectly but it doesn't because of those 2 tiny errors i can't fix. please help me. |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2017 09:01 AM |
| Which line(s) does it error on? |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2017 09:01 AM |
I also wanna know something about tables, how do i insert a variable based on a values name and give that variable a value aso? would it be...
mytable = {} table.insert(mytable, stat.Name) mytable[stat.Name] = stat.Value
? |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2017 09:04 AM |
these are the errors...
Workspace.SCRIPT:121: bad argument #2 to 'remove' (number expected, got string)
Workspace.SCRIPT:113: bad argument #1 to 'insert' (table expected, got nil)
these were the errors it was trowing. on line 121 and 113.
I am making a update on my anti-hack system that should protect your leaderstats and prevent hackers from changing leaderstats. |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2017 09:10 AM |
| did anyone find out why my script isn't working yet? |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2017 09:11 AM |
As with your other question, You can do this:
local table = {stringname = 5} Then you would access it by table.stringname giving you 5 |
|
|
| Report Abuse |
|
|
Zenuvius
|
  |
| Joined: 26 Aug 2014 |
| Total Posts: 551 |
|
|
| 06 Jan 2017 09:14 AM |
The second argument for table.remove is not the value rather it is the index,
local mytable = {"Hi", "lol", "Zen"}
Hi is [1], lol is [2], Zen is [3].
table.remove(mytable,3) will remove zen from the table.
-----
Have you tried FilteringEnabled ? Just asking first before anything, with FilteringEnabled on, you can worry much less regarding exploiters. It's not a foolproof anti exploit since you still have to write your own security for client-sided exploits however it does stop players from harming other players directly and manipulating said data.
If you haven't, you can try reading these links below for a start, use FE on a new place and try make a fireball script that replicates to every client. If you run into any errors, you can simply post it here and I'm sure people will help ^^
- Zenuvius |
|
|
| Report Abuse |
|
|
Zenuvius
|
  |
| Joined: 26 Aug 2014 |
| Total Posts: 551 |
|
|
| 06 Jan 2017 09:17 AM |
http://wiki.roblox.com/index.php?title=Security
http://wiki.roblox.com/index.php?title=API:Class/Workspace/FilteringEnabled
http://wiki.roblox.com/index.php?title=API:Class/RemoteEvent
http://wiki.roblox.com/index.php?title=API:Class/RemoteFunction
- Zenuvius
|
|
|
| Report Abuse |
|
|
Zenuvius
|
  |
| Joined: 26 Aug 2014 |
| Total Posts: 551 |
|
|
| 06 Jan 2017 09:25 AM |
If you want to remove by value, you can run a scan through the table for the value name and if it matches, make it remove the number, like so,
------------------------------------------------------------------------
local mytable = {"Hi","lol","Zen"}
local nameofvalueyouwanttoremove = "zen"
for i,v in pairs(mytable) do if v:lower() == nameofvalueyouwanttoremove:lower() then table.remove(mytable,i) end end
------------------------------------------------------------------------
- Zenuvius |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2017 09:26 AM |
@KritikalGunzz, Would't that trow an error?
|
|
|
| Report Abuse |
|
|
|
| 06 Jan 2017 09:27 AM |
| how do i add a status'name to a table and give it a value (int or number)? |
|
|
| Report Abuse |
|
|
Zenuvius
|
  |
| Joined: 26 Aug 2014 |
| Total Posts: 551 |
|
|
| 06 Jan 2017 09:48 AM |
For that it is probably better to use dictionaries,
http://wiki.roblox.com/index.php?title=Table#Dictionaries
with dictionaries, you can save more than just 1 value for a 'statusname'.
- Zenuvius |
|
|
| Report Abuse |
|
|
|
| 06 Jan 2017 11:59 AM |
@Ruby
Do that code and print(table.stringname)
See what it prints |
|
|
| Report Abuse |
|
|