Firing Remote Events :clone()

Hey Developers, I’m making this system where u press a button on a surfacegui and it fires an event saying what you have done and then duplicates a text label and puts it into a surfacegui, I’m a bit stuck as I cant find any errors in the console.

Panel Code (local script):

script.Parent.Black.MouseButton1Click:Connect(function(Player)
	game.ReplicatedStorage.LogEvent:FireServer(Player, "TechLog", "test123")
end)

Surface GUI (Script):

game.ReplicatedStorage.LogEvent.OnServerEvent:Connect(function(Player, log, message)
	if log == "TechLog" then
		local messagelog = script.TextLabel:Clone()
		messagelog.Parent = script.Parent.Parent.SurfaceGui.TechLogs.ScrollingFrame
		messagelog.Text = message
	if log == "SystemLog" then
			
	if log == "ExploitLog" then
				
			end
		end	
	end
end)

Any help would be appreciated. :heart:

1 Like

2 Issues here:

  1. MouseButton1Click doesn’t provide any arguments, so Player is nil
  2. Roblox automatically passes the player who fired the remote as the first argument on the server (Remove Player from there)

Your end placements are incorrect here (You can also use elseif or tables):

    if log == "TechLog" then
		local messagelog = script.TextLabel:Clone()
		messagelog.Parent = script.Parent.Parent.SurfaceGui.TechLogs.ScrollingFrame
		messagelog.Text = message
	elseif log == "SystemLog" then
	
	elseif log == "ExploitLog" then
			
	end
1 Like

Hm alright, I’ve made both of these adjustments and still nothings happening.

What do your new scripts look like

Server Script:

    if log == "TechLog" then
		local messagelog = script.TextLabel:Clone()
		messagelog.Parent = script.Parent.Parent.SurfaceGui.TechLogs.ScrollingFrame
		messagelog.Text = message
	elseif log == "SystemLog" then
	
	elseif log == "ExploitLog" then
			
	end

Local Script:

script.Parent.Black.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.LogEvent:FireServer("TechLog", "test123")
end)
1 Like

Make sure that on the server your Remote is still setup as

game.ReplicatedStorage.LogEvent.OnServerEvent:Connect(function(Player, log, message)

Check Whether The Localscript Is Being Executed

Print something at the start of the script to check.

Attempt to put the surface GUI into the PlayerGui as it only runs the local scripts when it is in PlayerGui.

Or you can execute the local script inside PlayerScripts.

Yep, done that it’s weird it wont even print something. I’ve never experienced this issue. Idk if the problem is because its a local script but even when I try:

script.Parent.Blue.MouseButton1Click:Connect(function()
print("test123456")
--game.ReplicatedStorage.LogEvent:FireServer("TechLog", "test123")
end)

Nothing happens.

1 Like

Have you checked if its actually being cloned? Try getting the GUI through PlayerGui Which is also better practice. please update me!

Found the issue, the surface GUI needed to be in StarterGUI and adorned to the Part for the local script, thank you for all your help though.