Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

2 comments

0

Just the ":"?

0

I did that with someone already and may help.

2 answers

✓ Accepted answer

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)

4 comments

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.

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.

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?

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.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.