How would I make it so this script only works if the text inside of the TextBox is equal to the player’s name?
local Players = game.Players
local LocalPlayer = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ModerationPanel = script.Parent.Parent.Parent
local UsernameBox = ModerationPanel.Username
local Button = script.Parent
local SilenceManager = ReplicatedStorage.SilenceManager
local SilencePlayer = SilenceManager:WaitForChild("SilencePlayer")
local NotifyPlayer = SilenceManager:WaitForChild("NotifyPlayer")
local Group = 13791384
local AllowedRank = 15
game.Players.PlayerAdded:Connect(function(Player)
if Player:GetRankInGroup(Group) >= AllowedRank then
Button.MouseButton1Click:Connect(function()
SilencePlayer:FireClient()
NotifyPlayer:FireClient(Player, "Panel", "The player has been muted.")
end)
end
end)
local Players = game.Players
local LocalPlayer = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ModerationPanel = script.Parent.Parent.Parent
local UsernameBox = ModerationPanel.Username
local Button = script.Parent
local SilenceManager = ReplicatedStorage.SilenceManager
local SilencePlayer = SilenceManager:WaitForChild("SilencePlayer")
local NotifyPlayer = SilenceManager:WaitForChild("NotifyPlayer")
local Group = 13791384
local AllowedRank = 15
game.Players.PlayerAdded:Connect(function(Player)
if Player:GetRankInGroup(Group) >= AllowedRank then
Button.MouseButton1Click:Connect(function()
if Player.Name ~= Button.Text then
return
end
SilencePlayer:FireClient()
NotifyPlayer:FireClient(Player, "Panel", "The player has been muted.")
end)
end
end)
local Players = game.Players
local LocalPlayer = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ModerationPanel = script.Parent.Parent.Parent
local UsernameBox = ModerationPanel.Username
local Button = script.Parent
local SilenceManager = ReplicatedStorage.SilenceManager
local SilencePlayer = SilenceManager:WaitForChild("SilencePlayer")
local NotifyPlayer = SilenceManager:WaitForChild("NotifyPlayer")
local Group = 13791384
local AllowedRank = 15
game.Players.PlayerAdded:Connect(function(Player)
if Player:GetRankInGroup(Group) >= AllowedRank then
Button.MouseButton1Click:Connect(function()
if Player.Name ~= UsernameBox.Text then
return
end
SilencePlayer:FireClient()
NotifyPlayer:FireClient(Player, "Panel", "The player has been muted.")
end)
end
end)
I’ve tried that as well, does it have anything to do with this?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local Panel = StarterGui.Panel
local SilenceManager = ReplicatedStorage.SilenceManager
local SilencePlayer = SilenceManager:WaitForChild("SilencePlayer")
local UnsilencePlayer = SilenceManager:WaitForChild("UnsilencePlayer")
local NotifyPlayer = SilenceManager:WaitForChild("NotifyPlayer")
local Reason = Panel.UI.ModerationPanel.SilenceReason
local function ChatEnabled(Enabled)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, Enabled)
end
local function Notification(Title, Text)
StarterGui:SetCore("SendNotification", {
Title = Title,
Text = Text
})
end
SilencePlayer.OnClientEvent:Connect(function()
Notification("Muted", "You have been silenced by an staff member for"..Reason.Text..". You can no longer communicate with others inside the chat.")
ChatEnabled(false)
end)
UnsilencePlayer.OnClientEvent:Connect(function()
Notification("Un-muted", "You have been un-silenced, you can now communicate with others within the chat.")
ChatEnabled(true)
end)
NotifyPlayer.OnClientEvent:Connect(function(Title, Message)
Notification(Title, Message)
end)
The script above is inside of a LocalScript and the other one is inside of a ServerScript.
That script seems alright, it’s just the way you’re handling the UI functions.
Usually you would have a remote event, and on the client, when the button is pressed, you would fire that to the server and handle it there. Yours however is different, because you just connected the function on the server which may cause bugs later down the line. I’ll try to fix it though.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ModerationPanel = script.Parent.Parent.Parent
local UsernameBox = ModerationPanel.Username
local Button = script.Parent
local LocalPlayer = Button:FindFirstAncestorWhichIsA("Player")
local SilenceManager = ReplicatedStorage.SilenceManager
local SilencePlayer = SilenceManager:WaitForChild("SilencePlayer")
local NotifyPlayer = SilenceManager:WaitForChild("NotifyPlayer")
local Group = 13791384
local AllowedRank = 15
if LocalPlayer:GetRankInGroup(Group) >= AllowedRank then
Button.MouseButton1Down:Connect(function()
local playerFound = Players:FindFirstChild(UsernameBox.Text)
if not playerFound then
return
end
SilencePlayer:FireClient(playerFound)
NotifyPlayer:FireClient(playerFound, "Panel", "The player has been muted.")
end)
end
Yea, that’s the problem. In the video, he’s making a mute command based on an event that is already sent to the server. You however are connecting something that’s supposed to be on the client, to the server which causes a lot of problems. Try to change that mute button into a remote event and see if it works.
Switch that script under Silence into a LocalScript, and paste this inside:
--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local SilenceManager = ReplicatedStorage.SilenceManager
local RequestSilence = SilenceManager:WaitForChild("RequestSilence")
local Button = script.Parent
local ModerationPanel = Button.Parent.Parent
local UsernameBox = ModerationPanel.Username
--//Functions
Button.MouseButton1Down:Connect(function()
RequestSilence:FireServer(UsernameBox.Text)
end)
Add a script in ServerScriptService and paste this inside:
--//Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Variables
local SilenceManager = ReplicatedStorage.SilenceManager
local RequestSilence = SilenceManager:WaitForChild("RequestSilence")
local SilencePlayer = SilenceManager:WaitForChild("SilencePlayer")
local NotifyPlayer = SilenceManager:WaitForChild("NotifyPlayer")
--//Controls
local Group = 13791384
local AllowedRank = 15
--//Functions
RequestSilence.OnServerEvent:Connect(function(player, playerNameToSilence)
if not playerNameToSilence or type(playerNameToSilence) ~= "string" or player:GetRankInGroup(Group) < AllowedRank then
return
end
local playerToSilence = Players:FindFirstChild(playerNameToSilence)
if not playerToSilence then
return
end
SilencePlayer:FireClient(playerToSilence)
NotifyPlayer:FireClient(player, "Panel", "The player has been muted.")
end)
Wait what about this script, it’s a LocalScript inside of StarterGUI.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local Panel = StarterGui.Panel
local SilenceManager = ReplicatedStorage.SilenceManager
local SilencePlayer = SilenceManager:WaitForChild("SilencePlayer")
local UnsilencePlayer = SilenceManager:WaitForChild("UnsilencePlayer")
local NotifyPlayer = SilenceManager:WaitForChild("NotifyPlayer")
local Reason = Panel.UI.ModerationPanel.SilenceReason
local function ChatEnabled(Enabled)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, Enabled)
end
local function Notification(Title, Text)
StarterGui:SetCore("SendNotification", {
Title = Title,
Text = Text
})
end
SilencePlayer.OnClientEvent:Connect(function()
Notification("Muted", "You have been silenced by an staff member for"..Reason.Text..". You can no longer communicate with others inside the chat.")
ChatEnabled(false)
end)
UnsilencePlayer.OnClientEvent:Connect(function()
Notification("Un-muted", "You have been un-silenced, you can now communicate with others within the chat.")
ChatEnabled(true)
end)
NotifyPlayer.OnClientEvent:Connect(function(Title, Message)
Notification(Title, Message)
end)