How to disable a script when a player says something

Hey Developers! I’ve been having trouble creating the following:

A simple script, where:
When the player says a target word (ex. "/disableparent)
The parent of the script is disabled.

You would just use the player chatted event and then, see if it is the word/command and if it is then change the disabled property on the script to true.

Example Code:

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == "/disableparent" then
			script.Disabled = true
		end
	end)
end)

Thanks so much! I was just complicating the script, I really appreciate it!

1 Like