Advertisement
VoidScripteay72

Untitled

Feb 28th, 2023
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2.  
  3. local function onChatted(player, message)
  4. if message:lower() == "explode" then
  5. local character = player.Character
  6. if character then
  7. -- Remove the character's humanoid, which will also remove all parts
  8. character:FindFirstChildOfClass("Humanoid"):Destroy()
  9. end
  10. end
  11. end
  12.  
  13. -- Connect the onChatted function to the player's Chatted event for all players in the game
  14. for _, player in ipairs(Players:GetPlayers()) do
  15. player.Chatted:Connect(function(message)
  16. onChatted(player, message)
  17. end)
  18. end
  19.  
  20. -- Connect the onChatted function to the player's Chatted event for new players that join the game
  21. Players.PlayerAdded:Connect(function(player)
  22. player.Chatted:Connect(function(message)
  23. onChatted(player, message)
  24. end)
  25. end)
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement