I’am using the RemoteEvent who open the text with value in team Police from other person, but this is working for only 1 person in team Police i wanna open this text for all in team Police i don’t why this is not working. How can i open this text for all people in team Police?
LocalScript
local tool = script.Parent
local player = script.Parent.Parent.Parent.Name
local players = game:GetService('Players')
local ppl = players.LocalPlayer
local Character = ppl.Character or ppl.CharacterAdded:Wait()
tool.CanBeDropped = true
tool.ManualActivationOnly = false
tool.RequiresHandle = false
local gui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
local button = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui'):WaitForChild('Phone')
local remote = game.ReplicatedStorage.RemoteEvent
button.Frame.Send.MouseButton1Click:Connect(function()
local value = gui.Phone.Frame.Content.ContentText
remote:FireServer(value)
game.Workspace[player].Humanoid:UnequipTools()
gui.Phone.Enabled = false
end)
Script
local remote = game.ReplicatedStorage.RemoteEvent
local players = game:GetService("Players")
local Teams = game:GetService("Teams")
remote.OnServerEvent:Connect(function(player,value)
for _, player in pairs(players:GetPlayers()) do
local gui = player:WaitForChild('PlayerGui')
local button1 = player:WaitForChild('PlayerGui'):WaitForChild('Message')
if player.Team == Teams["Policja"] then
gui.Message.Enabled = true
gui.Message.TextBox.Text = value
button1.Close.MouseButton1Click:Connect(function()
gui.Message.Enabled = false
end)
Its because the remote event seems to be firing 1 player. you need the local script to be doing FireAllServer is your mistake. Change fireserver to firallserver
local remote = game.ReplicatedStorage.RemoteEvent
local players = game:GetService("Players")
local Teams = game:GetService("Teams")
remote.OnServerEvent:Connect(function(player,value)
for _, plr in pairs(Teams.Policja:GetPlayers()) do
local gui = plr:WaitForChild('PlayerGui')
local button1 = gui:WaitForChild('Message')
button1.Enabled = true
button1.TextBox.Text = value
button1.Close.MouseButton1Click:Connect(function()
button1.Enabled = false
end)