I am currently trying to make a “Commands Playground” Type game. I am going to need this a lot but do not understand how to do it.
(sorry for poor explanation in advance) to explain further, I want to make it so when said player says, Example message, it happens to said player.
I have the whole “when player says thing, event happens” thing down,
I just don’t know how to detect that the player said something and the event only happens to that player.
(for reference I am trying to make it so that when a player says, I am speed, their speed increases.)
Also, the effect is only for the player that chatted that so you are good to go with that portion of script.
You just have to make it a server script and not a local script.
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if string.lower(message) == "I am speed" then
local humanoid = char:WaitForChild("Humanoid")
humanoid.WalkSpeed = 50
end
end)
end)
final script being this then?
(edit: can’t be right, not working. I can’t tell what I am missing.)
You can also use the New TextChatService for this as it has commands for this reason
ServerScript:
local IAmSpeed = Instance.new("TextChatCommand")
IAmSpeed.Parent = game:GetService("TextChatService")
IAmSpeed.PrimaryAlias = "I am speed"
IAmSpeed.Triggered:Connect(function(Source,Text)
local Player = game.Players:FindFirstChild(Source.Name)
local Char = Player.Character
Char:FindFirstChildOfClass("Humanoid").WalkSpeed = 50;
end)