Here is my Server Script
01 | local Allowed = { 'CRAZYQUACKY84' } |
02 |
03 | local ReplicatedStorage = game:GetService( 'ReplicatedStorage' ) |
04 | local RemoteManager = ReplicatedStorage:WaitForChild( 'RemoteManager' ) |
05 | local WarnManager = RemoteManager:WaitForChild( 'WarningManager' ) |
06 |
07 | game.Players.PlayerAdded:Connect( function (plr) |
08 | for _,a in pairs (Allowed) do |
09 | if plr.Name = = a then |
10 | plr.Chatted:Connect( function (warncmnd) |
11 | if string.sub(warncmnd, 1 , 5 ) = = ':warn' then |
12 | local plrToWarn = game.Players:FindFirstChild(string.sub(warncmnd, 7 )) |
13 | if plrToWarn then |
14 | WarnManager:FireClient( 'You have been given a warning by: ' ..plr.Name.. '\n Reason: Violating Terms of Service, if commited again will lead to a kick' ) |
15 | end |
16 | end |
17 | end ) |
18 | end |
19 | end |
20 | end ) |
Here is my local script in the UI.
01 | local ReplicatedStorage = game:GetService( 'ReplicatedStorage' ) |
02 | local RemoteManager = ReplicatedStorage:WaitForChild( 'RemoteManager' ) |
03 | local WarnManager = RemoteManager:WaitForChild( 'WarningManager' ) |
04 |
05 | WarnManager.OnClientEvent:Connect( function (msg) |
06 | wait( 1 ) |
07 | script.Parent.WarningTitle.Text = msg |
08 | wait( 3 ) |
09 | script.Parent.WarningTitle.Text = '' |
10 | end ) |
I am trying to get it to write a command to send a UI message to a specific player.
The remote "WarnManager" is a remote event, so it takes a player object as its first argument.
You only did :FireClient with a string as an argument, you forgot to include the player being warned (plrToWarn) as the first argument.
:FireClient() Does not exist. Instead you need to do :FireAllClients(). If you want to send it to a specific player you need to do this for example:
Serverscript:
1 | game.Players.PlayerAdded:connect( function (player) |
2 | game.ReplicatedStorage.RemoteEvent:FireAllClients(player) |
3 | end ) |
Localscript:
1 | game.ReplicatedStorage.RemoteEvent.OnClientEvent:connect( function (player) |
2 | if player.Name = = game.Players.LocalPlayer.Name then |
3 | --function |
4 | end |
5 | end ) |
In your case this would be:
Serverscript:
01 | local Allowed = { 'CRAZYQUACKY84' } |
02 |
03 | local ReplicatedStorage = game:GetService( 'ReplicatedStorage' ) |
04 | local RemoteManager = ReplicatedStorage:WaitForChild( 'RemoteManager' ) |
05 | local WarnManager = RemoteManager:WaitForChild( 'WarningManager' ) |
06 |
07 | game.Players.PlayerAdded:Connect( function (plr) |
08 | for _,a in pairs (Allowed) do |
09 | if plr.Name = = a then |
10 | plr.Chatted:Connect( function (warncmnd) |
11 | if string.sub(warncmnd, 1 , 5 ) = = ':warn' then |
12 | local plrToWarn = game.Players:FindFirstChild(string.sub(warncmnd, 7 )) |
13 | if plrToWarn then |
14 | WarnManager:FireAllClients( 'You have been given a warning by: ' ..plr.Name.. '\n Reason: Violating Terms of Service, if commited again will lead to a kick' , plr, plrToWarn) |
15 | end |
16 | end |
17 | end ) |
18 | end |
19 | end |
20 | end ) |
localscript:
01 | local ReplicatedStorage = game:GetService( 'ReplicatedStorage' ) |
02 | local RemoteManager = ReplicatedStorage:WaitForChild( 'RemoteManager' ) |
03 | local WarnManager = RemoteManager:WaitForChild( 'WarningManager' ) |
04 |
05 | WarnManager.OnClientEvent:Connect( function (msg, plrToWarn) |
06 | if plrToWarn.Name = = game.Players.LocalPlayer.Name then -- Not sure if you want it like this but I hope you get the idea. |
07 | wait( 1 ) |
08 | script.Parent.WarningTitle.Text = msg |
09 | wait( 3 ) |
10 | script.Parent.WarningTitle.Text = '' " |
11 | end |
12 | end ) |