Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't RemoteEvent FireAllClients work?

I am making a painting game where players can change pixel colors on a SurfaceGui in order to paint a Canvas. This process is all local. Then, the player clicks a done button and the canvas, which was local, is supposed to duplicate somewhere where everyone can see it. I have this localscript, when the button is pressed. This RemoteEvent works as it is supposed to.

LocalScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local duplicate = ReplicatedStorage:WaitForChild("duplicate")
local pasteEvent = ReplicatedStorage:WaitForChild("paste")
 
script.Parent.MouseButton1Click:connect(function()
duplicate:FireServer()
end)

The duplicate Remote Event ServerScript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local duplicate = ReplicatedStorage:WaitForChild("duplicate")
local PaintingLandscape = workspace.PaintingLandscape
local pasteEvent = game.ReplicatedStorage.paste
 
local function onClone(player)
	local clonepainting = PaintingLandscape:Clone()
	clonepainting.Name = "Canvas"
	clonepainting.Position = Vector3.new(-13.99, 5, 0.431)
	clonepainting.Parent = game.Workspace
	local cloneGUI = player.PlayerGui.Studio.Canvas:Clone()
	cloneGUI.Name = "Painting"
	cloneGUI.Parent = game.ReplicatedStorage
	cloneGUI.Adornee = clonepainting
	pasteEvent:FireAllClients()

end

duplicate.OnServerEvent:connect(onClone)

Once again, this works fine. However, the pasteEvent:FireAllClients() line does not fire. This is the local script that is supposed to fire for all clients:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local pasteEvent = ReplicatedStorage:WaitForChild("paste")
local painting = game.ReplicatedStorage.Painting
 
local function onPaste()
	wait(1)
	local clone = painting:Clone()
	clone.Parent = player.PlayerGui
	clone.Adornee = workspace.Canvas
end
 
pasteEvent.OnClientEvent:Connect(onPaste)

If anyone could figure out this problem, or at least make an attempt, I would really appreciate it! :)

3 comments

0

@RockerCaleb1234 I always struggle to use them because I don't understand how they work. I've read the wiki but it is complicated for me. Would it be easy to convert this to a Remote Function?

0

A simple solution for this would be to make a second remote that the server uses to connect to your 2nd local script. Idk if this is the best way though.

0

@RockerCaleb1234 Why doesn't this script work in the first place?

2 answers

Okay I figured it out to anyone having the same issues. I needed to put the last localscript in StarterPlayerScripts.

You cannot have a client use :FireAllClients(), probably because of security issues. Instead, fire a remote event to the server to fire :FireAllClients().

This discussion is preserved as it was. New answers, comments, and votes are closed.