Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Could someone help me with an admin command that explodes?

Asked by 5 years ago

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

0
What you mean under ,,Breaks the chat"? Miniller 562 — 5y
0
It doesn't let me chat AidanTES 36 — 5y
0
is this a serverscript or a localscript AAzterr 27 — 5y
0
Test it in game and not in studio, there seems to be issues with using the chat in studio. EpicMetatableMoment 1444 — 5y

1 answer

Log in to vote
0
Answered by
Isaque232 171
5 years ago
Edited 5 years ago

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

0
Hey thanks! I'll try it. AidanTES 36 — 5y
0
It doesn't work. Do I need FE off? AidanTES 36 — 5y
0
Oh wait I forgot it was an R15 game nvm AidanTES 36 — 5y
0
It's still not working? AidanTES 36 — 5y
View all comments (2 more)
0
Just tested the script with the things I said you'd need to modify again and it worked fine. Of course the game needs to be FE, you don't really need to put it specifically on the torso, can put just in the Character for example. Isaque232 171 — 5y
0
The script also should be in a serverscript, make sure you did type the correct phrase to execute it, edited my answer so It'll work no matter if you used caps or not, make sure to check it. Isaque232 171 — 5y
Ad

Answer this question