Explode when player says Specific word

I am making a ragdoll game where I want the player to explode when he says a specific word on chat

I have made a script but it does not seem to work it just says instance does not exist.

Here is the script:

local PlayersService = game:GetService(“Players”);
local StringToDetect = “lol”;

PlayersService.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if string.find(string.lower(Message), string.lower(StringToDetect)) then
if Player.Character then
local explosion = Instance.new(“Explosion”)
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters – damages terrain
explosion.Parent = game.Workspace
end;
end;
end);
end);

Could you elaborate this? I don’t have sufficient information to figure out the problem.

I had changed the script the one I posted about is the newest one I tried making. But the old one used to Say Instance does not exist when I said the specific word in the chat. But for the new script, it says nothing in Output.

@anon81993163 Happy anniversary!

Also I believe you need to position the explosion to the Player’s Character? Try this:

local PlayersService = game:GetService(“Players”);
local StringToDetect = "lol";

PlayersService.PlayerAdded:Connect(function(Player)
    print("Player added")
    Player.Chatted:Connect(function(Message)
        if string.find(string.lower(Message), string.lower(StringToDetect)) then
            if Player.Character then
                print("Creating the explosion")
                local explosion = Instance.new("Explosion")
                explosion.BlastRadius = 60
                explosion.ExplosionType = Enum.ExplosionType.Craters – damages terrain
                explosion.Position = Player.Character.HumanoidRootPart.Position
                explosion.Parent = game.Workspace
                print("Explosion created")
            end;
        end;
    end);
end);
1 Like

I don’t know if you knew but ; isn’t used in lua and you forgot to set the explosions position

local PlayersService = game:GetService(“Players”)
local StringToDetect = “lol”

PlayersService.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if string.find(string.lower(Message), string.lower(StringToDetect)) then
if Player.Character then
local explosion = Instance.new(“Explosion”)
explosion.BlastRadius = 60
explosion.ExplosionType = Enum.ExplosionType.Craters – damages terrain
explosion.Parent = game.Workspace
exploision.Position = player.Character.Head.Position
end
end
end)
end)
1 Like

You can use ; in Lua (It just isn’t necessary).

1 Like

I Tested the script and it worked. Silly me didn’t notice I forgot to put the Position. Thank you!