Oh, it’s because it’s listening for if a event has fired for the client.
Also kicking from the client won’t work. You have to fire a remote to do that.
Okay, but I was mainly looking for the ban part. Any clue?
Listen for whenever the client submits the command
What do you mean by that?
commandSubmitButton.MouseButton1Click:Connect(onSubmit)
Mkay…I don’t understand totally what you mean, but I think you mean for banning watch for it to be clicked.
game.ReplicatedStorage.GuiRemoteEvents.Banning.OnServerEvent:Connect(function(placeholder, victim, plr)
What does the argument “placeholder” here mean?
When you were firing the event:
game.ReplicatedStorage.GuiRemoteEvents.Banning:FireServer(plr.Name, player)
You had only 2 arguments.
That means that “plr” in the previous function has no value, that explains why your value is getting set to nothing.
Tell me if that fixed anything!
It didn’t help. It still outputs the same thing, and no StringValue is made either.
I think the problem is that you are replicating too much (Sending too many requests) therefor sometimes it wont replicate.
For now I really don’t have a single idea what is going on, I tried it myself and it does it perfectly fine.
The variable player
hasn’t been set on the client, only plr, so when you send that nil value to the server you’re trying to set a string value to nil. Was there any error in the server log?
I don’t understand your script, didn’t teleport, kick or ban should be done in the server (Of course you can do it in client, if you wish )? I saw you use OnClientEvent, if it is fire from the server script, why not do all the thing in the server script instead of firing remote.
I guess you have a logical error here.
I actually don’t have any clue on your problem. I want to know if the script print(player) and print(“Test.”)
I would suggest you to use PlaceHolder.UserId instead of victim, this can decrease the request. (As well as the player
(in client side) / plr
(in server side) in you script)
Using ID can avoid the ban script cannot detect the player that have changed his name. Or you can save it as a ban log.
Please format your code properly so it’s easier to read. This can be achieved by placing two backticks before and after your code.
```lua
-- Your code
```
To be honest, in general, I think the error is in the way you wrote the code more than anything. There’s a couple of things giving me grief in which are inhibiting my ability to provide good feedback:
- Extreme code vulnerabilities
- Nested if statements
- Firing the LocalPlayer to a remote when the player is automatically passed as the first argument for OnServerEvent
You also tried setting the value of a StringValue to a userdata object. That won’t fly.
I know my coding isn’t the best, but that’s not the problem with the code.
What is the problem then? I don’t understand. There’s two blocks of code (and please fix your formatting, again) and a typed message. That doesn’t help me understand the problem. I don’t even know what the console looks like when it throws that error.
I’ve said the output two times it says the packet won’t process. Whatever that means.
Try remove plr:Kick("You have been banned by ".. player ..". If you have a problem with this talk to a SHR.")
and see if it works. It is probably a problem on why pocket cannot be successfully sent.
Okay, I’ll see if it works.
Hi there, here’s some help with the topic:
For your client script I suggest to check whether “player” is nil or not and ignore the call otherwise or else when the nil gets to the “print(player)” it will supposedly error out your script and not fire the ban event in the first place.
RemoteEvents fire server-side with the first value being the Client (player) that fired it, if it’s not intentional I suggest removing “placeholder” as an argument and making sure that victim and plr are not equal to nil as well.
And here are some suggestions that I can make to improve your scripts as a whole:
Client
-
Avoid teleporting/destroying parts locally for specifically an admin script or you may wind up encountering bugs such as people not actually dying when you destroy their head or not actually teleporting on their screen, or your anti-exploit (if you hopefully have one in this case) kicking people because they are teleporting around locally which is indicative of an exploiter in some cases outside of ping/lag.
-
Do not kick other users on the client script, it does not work as “When used from a LocalScript, only the local player’s client can be kicked.” (Player | Documentation - Roblox Creator Hub)
Server
-
Update the name and value of the StringValue you’re making before parenting it, out of good practice in cases where a script checks when ChildAdded is fired.
-
If you are banning someone only on that server you can just add the player’s name to a table and check to see if someone is in that table when they join, rather than taking some extra effort from the server-side in such a case that it doesn’t work (i.e. in this one).
-
Sanity check the ban event firing, checking whether the client (Player) is actually an admin or not or else you may wind up in a sticky situation if an exploiter finds that they can fire it as they please. As a rule of thumb with remote events receiving traffic from the client, never trust they’ll do the right thing and you’ll be fine as far as security is concerned.
In General
- It’s easier to debug your code when everything is properly indented and whitespace consistently (and hopefully not overly so), so I definitely suggest saving yourself and others a headache.
And sorry for the long response, I just hope that some of it at minimum helped!
The server is unable to process the packet sent via the RemoteEvent because the client which sent it doesn’t exist.
Ignoring everything else, you can comment out line 29 of your localscript or yield (a remotefunction can be used in this case) until the server completes the task before line 29 and the stringvalue will be created successfully.
I highly recommend you re-think what you’re trying to achieve, which appears to be some form of administrative tool. As it stands, you’re throwing around arbitrary variables and you’re relying on the server instructing the client on what to do (changes you make on the client won’t replicate). It’s also possible for the client to ban any user due to there being no server-sided validation by simply running the following code:
game:GetService("ReplicatedStorage").GuiRemoteEvents.Banning:FireServer("{VictimHere}", "{AdministratorHere}")
I’d recommend listening on the server, validating the user has permission to execute the command and then executing the command on the server. “pseudocode”:
local Admins = {}
local function isAdmin(Player)
for _, id in pairs(Admins) do
if id == Player.UserId then
return true
end
end
return false
end
game:GetService("ReplicatedStorage").RemoteEvent.OnServerEvent:Connect(function(Player, Command, Victim)
if isAdmin(Player) then
-- if command == x, do y
end
end)
from the client…
game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent"):FireServer("Ban", game:GetService("Players").{Victim})
I’d also like to note that you shouldn’t send the localplayer as an argument using :FireServer
, since the LocalPlayer is already passed automatically to the server and will always be the first argument. This cannot be manipulated, unlike sending the localplayers name to validate it’s identity as an argument.