It’s supposed to input username, then it gets transformed into userid through useridfromnameasync and then sets the id to true and the player is kicked, ban handler kicks them again when they rejoin.
May I see this function though?
local cache = {}
function getUserIdFromUsername(name)
if cache[name] then return cache[name] end
local player = Players:FindFirstChild(name)
if player then
cache[name] = player.UserId
return player.UserId
end
local id
pcall(function ()
id = Players:GetUserIdFromNameAsync(name)
end)
cache[name] = id
return id
end
I got it from here. Players | Roblox Creator Documentation
From the roblox’s example which shows us how to use it.
I still have no clue whatsoever that could be the problem. Maybe the client script isn’t working as intended? Try debugging the issue there by printing Target.Text
.
It printed correctly, no idea…
Hey! Can you send any errors you get? That would be appreciated! Thanks!
Not quite the solution there, the issue was originally on setting the data there. Perhaps you’re getting stopped by this?
Maybe I am. Let me remove it and try, and if it does work then… How would I secure the remote?
Sadly that was not the problem! aaaaaaaaaaaaaaaaaah
Looks like we’re going nuclear then. Run a full print-debugging method to see where the lines stop by throwing in printing functions between lines.
Printed up until print(“above setasync”) and then it died.
ban.OnServerEvent:Connect(function(player, playerToBan, reason)
if not table.find(ADMIN, player.UserId) then return end
print("below table.find")
playeruserID = getUserIdFromUsername(playerToBan)
print("below playeruserID definition")
if playeruserID == 1 then
print("below playeruserid == 1")
print("Cannot Ban This User!")
return
else
local success, errormessage = pcall(function()
print("above setasync")
BanData:SetAsync(playeruserID, true, reason)
print("below setasync")
end)
if success then
print("above playertoban = this and that")
local playerToBan = Players:GetPlayerFromUserId(playeruserID)
print("below playertoban")
if playerToBan.Parent then
print("below playertoban.parent")
playerToBan:Kick(reason)
print("below :kick")
else
return
end
end
end
end)
Looks like you’re setting one argument too many. Besides, true
isn’t needed. Just do BanData:SetAsync(playeruserID, reason)
. If the entry(or reason) exists, then they were banned.
I’ll try it out tomorrow, thanks.
That is false, you can send instances, but its reference will be nil unless the instance exists on both the client and server.
The third parameter has to be an array ({}).
This should be enough:
:SetAsync(Key, Reason)
There is no reason to use the extra parameters if they are never being used in the future, that is most likely why it stops.
You haven’t defined ADMIN here.
simple do local banplayer = playerid
but you want to do datastore so make a value for the banned player try it