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

Any way to detect if a person says ":"?

Asked by
lomo0987 250 Moderation Voter
10 years ago

I am looking to see if there is a way that will detect if a player says something like ":Kill others" and it would detect that person has said ":" before everything else. I know you can detect words, but i don't know if you can just detect a single part of the word.

0
Just the ":"? HexC3D 830 — 10y
0
I did that with someone already and may help. HexC3D 830 — 10y

2 answers

Log in to vote
3
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

This is not a request site, but since your request is easy I will assist you.

game:GetService("Players").PlayerAdded:connect(function(s) --You need to connect to the player, so the player's name is 's'.
s.Chatted:connect(function(m) --Whenever 's' says something, then the function executes.
if m:sub(1,1) == ":" then --If he says : before anything then the next few lines will run.
--What do you want to do to the speaker 's'?
end
end)
end)
0
What i'm trying to do is make a ban system that updates to the server using datasave. I will also need it so those who have admin, (I would put the names in there) wouldn't get banned. lomo0987 250 — 10y
0
Well, please remember that Scripting Helpers is not a request site and you will need to contribute work before we may continue helping you. M39a9am3R 3210 — 10y
0
Yeah, I know. I just like to have the basics then work on it myself. I just gave you the idea of what i'm trying to do. Should this be a local script inside a player or within Workspace? lomo0987 250 — 10y
0
It should be in regular script in ServerScriptService or Workspace for two reasons, 1) It's using the PlayerAdded event which won't properly execute in a local script under the player. 2) You intend to use DataStores which is cautioned by the ROBLOX wiki that you use the feature in a Server Side script in order to have the feature work as intended. M39a9am3R 3210 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Erm..

game.Players.PlayerAdded:connect(function(p)
    p.Chatted:connect(function(msg)
        if msg:sub(1,12) == ":Kill others" then
            for i,v in pairs(game.Players:GetPlayers()) do 
                if v.Name ~= p.Name then
                    repeat wait() until v.Character
                    v.Character:BreakJoints()
                end
            end
        end
    end
end)

Try it. It has no admin, you'll have to implement it yourself, but if someone types in ':Kill others', it would 'kill' other players, besides them.

Answer this question