How to make it so that there is one specific message that if a player says it a script is disabled but when saying another specific message the script is enabled
like this?
,
local Scriptforblablabla = game.Workspace.Script -- Example
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == "enable the script" then
Scriptforblablabla.Disabled = false
elseif Message == "disable the script" then
Scriptforblablabla.Disabled = true
end
end)
end)
It’s better to have the script execute that code without disabling it. You can put a boolean variable inside it like so:
local Check = false
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player) -- Fires every time a player join's
Player.Chatted:Connect(function(Message) -- Fires when player typed a message in chat
if Message == "-Specific word-" then
--function
Check = true
end
if Message == "-Second Specific word-" then
--function
Check = false
end
end)
end)
EDIT: Though in this case i’m not sure why the boolean would be used. But for all intensive purposes, it’s there. You can remove it if you want.
tbh this is more efficient cuz ma script is just efficient on disabling triggering functions
No there is no difference in efficiency whether disabling scripts or using booleans. But it certainly is a better idea to not disable scripts, because if the original script that enable’s it error’s, then the disabled script can’t really do anything, like at all. (If that script has detectors like .Changed or :GetPropertyChangedSignal())
ok, lemme see let me try this scirpt