Currently using Robase to kick anyone who’s present in a firebase table using Robase but I’m getting very confused around tables and arrays, here is my code, let me know if you need any more information.
Code:
local RobaseServiceModule = require(script.Parent.RobaseService)
local RobaseService = RobaseServiceModule.new(removed_for_devforum)
local Robase = RobaseService:GetRobase()
local Success, playertable = Robase:GetAsync("player")
print(playertable)
local HTTPService = game:GetService("HttpService")
game:GetService("Players").PlayerAdded:Connect(function(player)
local tablee = HTTPService:JSONEncode(playertable)
if table.find(tablee, player) then
player:Kick()
end
end)
Firebase Structure:
Thank you for any help, and thanks for making this module!
I believe the issue is that the player
array you store has elements set as datatype strings. The issue arises when you crosscheck the array with the player instance.
Your check consists of:
if table.find(tablee, player) then
player:Kick()
end
You’re checking to see if the playerInstance of the player exists in an array that consists of strings.
Try this:
local RobaseServiceModule = require(script.Parent.RobaseService)
local RobaseService = RobaseServiceModule.new(removed_for_devforum)
local Robase = RobaseService:GetRobase()
local Success, playertable = Robase:GetAsync("player")
print(playertable)
local HTTPService = game:GetService("HttpService")
game:GetService("Players").PlayerAdded:Connect(function(player)
local tablee = HTTPService:JSONEncode(playertable)
if table.find(tablee, player.Name) then
player:Kick()
end
end)
Furthermore, I think you should move away from using the name, and towards using the UserID. A player’s name can be changed for 1,000 ROBUX, but a UserID can never be changed. If you replace your firebase table with userIDs, the code would become:
local RobaseServiceModule = require(script.Parent.RobaseService)
local RobaseService = RobaseServiceModule.new(removed_for_devforum)
local Robase = RobaseService:GetRobase()
local Success, playertable = Robase:GetAsync("player")
print(playertable)
local HTTPService = game:GetService("HttpService")
game:GetService("Players").PlayerAdded:Connect(function(player)
local tablee = HTTPService:JSONEncode(playertable)
if table.find(tablee, (player.UserId)) or table.find(tablee, tostring(player.UserId)) then -- checks for both number element and string element, depending on how you store it
player:Kick()
end
end)
1 Like
Thank you, and yes it was a stupid mistake, anyway I plan to have it automatically add the user id as a child of the name once it first detects them ingame, so thanks for saving me that bit of time with the code .