Instance not working

This is the client.

local plr = game.Players.LocalPlayer

game.ReplicatedStorage.GuiRemoteEvents.Command.OnClientEvent:Connect(function(player, command, victim)
	
	local me = string.lower(plr.Name)
	
	if me == victim then
		
		if command == "Bring" then
			
			plr.Character:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(1, 1, 3) * game.Workspace:FindFirstChild(player):FindFirstChild("HumanoidRootPart").CFrame
			
		elseif command == "To" then
			
			game.Workspace:FindFirstChild(player):FindFirstChild("HumanoidRootPart").CFrame = plr.Character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(1, 1, 3)
			
		elseif command == "Reset" then
			
			plr.Character:FindFirstChild("Head"):Destroy()
			
		elseif command == "Reset" then
			
			plr:Kick("You have been kicked by".. player ..". If you have a problem with this talk to a SHR.")
			
		elseif command == "Ban" then
			
			print(player)
			game.ReplicatedStorage.GuiRemoteEvents.Banning:FireServer(plr.Name, player)
			plr:Kick("You have been banned by ".. player ..". If you have a problem with this talk to a SHR.")
			
		end
		
	end
	end)

This is the server script.

game.ReplicatedStorage.GuiRemoteEvents.Banning.OnServerEvent:Connect(function(placeholder, victim, plr)
	
	print("Test.")
	local Ban = Instance.new("StringValue")
	Ban.Parent = script.Parent.BanList
	Ban.Name = victim
	Ban.Value = plr
	
end)

For some reason it doesn’t make the value in the server script. The output says something about the packet not processing.

I have tried many things suggested by the discord server scripting helpers, but I couldn’t find help there. Anyone have a clue why it isn’t putting a stringvalue in the BanList?

Why are you listening from the server for input from the client?
I.e why are you listening for OnClientEvent when this is input from the client.
Slightly unrelated but why are you kicking from the client?

1 Like

Where?

game.ReplicatedStorage.GuiRemoteEvents.Command.OnClientEvent:Connect(function(player, command, victim)

Hmm, let me check that out.

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 :thinking:)? 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.

1 Like

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.