How to make a gui appear for all player when a part button is pressed

  1. What do you want to achieve?
    when a player presses a part button (not a gui!) it will show everyone in the server a textlabel

  2. What is the issue?
    ma script dont work

  3. What solutions have you tried so far?
    i have looked at many forums in the devfourms and it still dosent work i have tryed to use remote event but am not good at it so it still dosent work

My local script

local repliatcedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local RemoteEvent = repliatcedStorage.RemoteEvent
local Gui = script.Parent.TextLabel

local Button = workspace.Game.HallWay1.Office1.LockDown.BaseButton.StartLD
local StopButton = workspace.Game.HallWay1.Office1.LockDown.BaseButton.EndLD

local function PressedButton()
	Gui.Visible = true
	wait(3)
	Gui.Visible = false
end

Button.ClickDetector.MouseClick:Connect(function()
	RemoteEvent.OnClientEvent:Connect(PressedButton)
end)

My server script

local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local player = game:GetService("Players")

local Button = workspace.Game.HallWay1.Office1.LockDown.BaseButton.StartLD

local function ShowMessage(player)
	RemoteEvent:FireAllClients()
end

player.PlayerAdded:Connect(ShowMessage)
1 Like

You did not connect up a function on the client, to recieve the signal.

RemoteEvent.OnClientEvent:Connect(function()
--
end)
1 Like
-- ServerScript

-- you don't need 'Players'
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local Button = workspace.Game.HallWay1:WaitForChild("Office1").LockDown.BaseButton.StartLD
local StopButton = workspace.Game.HallWay1.Office1.LockDown.BaseButton.EndLD

local function ShowMessage() -- you don't need player for :FireAllClients()
	RemoteEvent:FireAllClients()
end

player.PlayerAdded:Connect(ShowMessage)
Button.ClickDetector.MouseClick:Connect(ShowMessage) -- click on the server instead
-- LocalScript
local repliatcedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local RemoteEvent = repliatcedStorage.RemoteEvent
local Gui = script.Parent.TextLabel

local function PressedButton()
	Gui.Visible = true
	wait(3)
	Gui.Visible = false
end
-- you'll only need to listen to the RemoteEvent
RemoteEvent.OnClientEvent:Connect(PressedButton)
2 Likes

Thank you so much i will centrally try to learn more about remote events but for now thank you

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.