I am trying to make an admin command system but, I can't seem to get anything to work! Here are a couple examples:
game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) if(msg == ":explode") then local splode = Instance.new("Explosion") splode.Parent = player.Torso splode.BlastPressure = 500000 splode.BlastRadius = 4 splode.DestroyJointRadiusPercent = 1 splode.ExplosionType = "Craters" splode.Visible = true splode.Archivable = true end end) end) -- Breaks the chat
game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) if msg == ":explode" then local splode = Instance.new("Explosion") splode.Parent = player.Torso splode.BlastPressure = 500000 splode.BlastRadius = 4 splode.DestroyJointRadiusPercent = 1 splode.ExplosionType = "Craters" splode.Visible = true splode.Archivable = true end end) end) -- Also breaks the chat
I've tried and tried but nothing is working!
If someone could give me some sort of tutorial (As tutorials I've tried are most likely outdated because they don't work) in the answers that would be very appreciated thank you!
-Aidan
You should try to test it in-game when you're testing chat scripts, for some reason the chat also bugs in studio for me.
I tested your script ( from a server script ) and I noticed that you're trying to access the player torso through the player variable which the PlayerAdded event gave to you, that won't work, you should access it by going on the player's char and accessing it from there, also :connect is deprecated so try to use :Connect instead.
So you should add a variable 'char' on your script so you can access the player's char easily, such as: ( needs to be below the PlayerAdded or Chatted function )
local Char = player.Character or player.CharacterAdded:wait()
and then you can easily access the torso with that, you'd need to change splode.Parent = player.Torso to splode.Parent = Char.Torso
It seems that you're also trying to put the explosion position to the player's position but you actually didn't, you can set It's position to the player's humanoid by using
splode.Position = Char.HumanoidRootPart.Position -- ( or Char.Torso.Position)
Also just to prevent you from doing :Explode or :EXPLODE and it not working, you can use string.lower to prevent things like this from happening, so the player doesn't need to type exactly ":explode" without caps and things like so for it to work.
For that to be solved you'd need to modify:
if(msg == ":explode") then
to
if(string.lower(msg) == ":explode") then
Hopefully those solve your issue! Make sure to accept the answer if it did. :)