Script not working

I am trying to make it that when you click the nuke button it alerts the whole server that the player has bought Nuke, But it isn’t working?
Script:

local RS = game:GetService("ReplicatedStorage")
local Nuke = RS.HasBoughtNuke

game.StarterGui.Nuke.TextButton.MouseButton1Up:Connect(function()
	Nuke:FireAllClients()
end)

Local Script:

local RS = game:GetService("ReplicatedStorage")
local Nuke = RS.HasBoughtNuke
local NukeText = game.Players.LocalPlayer.PlayerGui:WaitForChild("Nuke").TextLabel
local Player = game.Players.LocalPlayer
local function Texting(object, text)
	for i = 1, #text, 1 do
		object.Text = string.sub(text, 1, i)
		wait(0.05)
	end
end

Nuke.OnClientEvent:Connect(function()
	Texting(NukeText, Player.Name.." Has bought nuke!")
end)

  1. use playerGui not startergui (game.Players.LocalPlayer.PlayerGui)

  2. use a local script
    TextButton.MouseButton1Up is localScript only

Firing an event only works in a server script, right?

no. both. FireServer and InvokeServer are on client

FireClient, FireAllClients, OnServerEvent, OnServerInvoke are called/fired from server.

I wanna fire the message to clients not the server, Since mousebutton doesn’t work in server what should i use?

1 Like

I wouldn’t be able to fire it to all clients if I putted it in a local script, Still won’t work

you could fire an event from client to server to all clients

Which I don’t know how i can do a triple communication ;-;

client:

local remote = game.replicatedstorage.ramote
button = yourbutton
button.Activated:connect(function()
   remote:FireServer()
end)

remote.OnClientEvent:Connect(function(player)
   notify that player has bought the nuke
end)

server:

remote = da remote
remote.OnServerEvent:Connect(function(player)
   remote:FireAllClients(player)
end)

this is a very basic example, it doesnt work but it should give you the idea

2 Likes

Thank you so much! It works, Best example

2 Likes