EconomicSerg

Kick script

Feb 22nd, 2021 (edited)
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. -- You need three things:
  2. -- 1. A ScreenGui with a TextBox named Username, another TextBox named Reason, and a  button named Kick
  3. -- 2. A RemoteEvent named KickPlayer
  4. -- 3. 2 Scripts
  5.  
  6. -- Add a LocalScript into the gui
  7.  
  8. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  9. local RemoteEvent = ReplicatedStorage:WaitForChild("KickPlayer") -- Change it to the name of the remote event
  10. local button = script.Parent.Kick
  11. local player = script.Parent.Username.Text
  12. local reason = script.Parent.Reason.Text
  13.  
  14. button.MouseButton1Click:Connect(function()
  15.         if game.Players:FindFirstChild(player) then
  16.             RemoteEvent:FireServer(player, reason)
  17.         end
  18. end)
  19.  
  20. -- Server Script
  21.  
  22. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  23. local RemoteEvent = ReplicatedStorage:WaitForChild("KickPlayer") -- Change it to the name of the remote event
  24.  
  25. RemoteEvent.OnServerEvent:Connect(function(player, username, reason)
  26.         game.Players:FindFirstChild(username):Kick("\nYou were kicked for\n"..reason.."\n")
  27. end)
Add Comment
Please, Sign In to add comment