Remote Events and how to use them

Hello everyone I am trying to learn how to use remote events still, and I am not sure if I did it correctly. This is my Local Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Testing = ReplicatedStorage:WaitForChild("DevKing?")

local Gui = game.Players.LocalPlayer.PlayerGui.OpenLightsaber

Gui.Frame.MouseButton1Down:Connect(function()
	Gui.Frame.Visible = true
	Testing:FireServer(Gui)
end)

The goal of this is to be able to find my gui and open it. I then called the remote event in the script inside this script:

local gear = script.Parent
local attackAnim = script.attack
local tool = script.Parent
local cooldown = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Testing = ReplicatedStorage:WaitForChild("DevKing?")

gear.Activated:Connect(function()
	
	Testing.OnServerEvent:Connect(function(player,Gui)
	local humanoid = gear.Parent:FindFirstChildWhichIsA('Humanoid')
	if cooldown == false then
		cooldown = true
		local loadedAnim = humanoid:LoadAnimation(attackAnim)
		loadedAnim:Play()
		local canDamage = script.Parent.canDamage
		canDamage.Value = true
		wait(1)
		loadedAnim:Stop()
		canDamage.Value = false
			cooldown = false
		end	
	end)
end)

The gui would open when the tool is activated.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Testing = ReplicatedStorage:WaitForChild("DevKing?")

local Player = game.Players.LocalPlayer
local Gui = Player:WaitForChild("PlayerGui").OpenLightsaber -- use "WaitForChild" because it doesn't replicate immediately
-- separate variables 

Gui.Frame.MouseButton1Down:Connect(function()
	Gui.Frame.Visible = true -- this could be kept here or changed
	Testing:FireServer() -- you don't need the client to send it, the server can get it from PlayerGui.
    -- any changes the player made on the gui (such as typing in a texbox), won't replicate.
end)
local gear = script.Parent
local attackAnim = script.attack
local tool = script.Parent
local cooldown = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Testing = ReplicatedStorage:WaitForChild("DevKing?")

gear.Activated:Connect(function()
    -- everytime the tool is activated, it'll bind a new function to the remote event, you should disconnect it when you don't need it

 Testing.OnServerEvent:Connect(function(player)
      -- player:WaitForChild("PlayerGui").OpenLightsaber.Frame.Visible = true
      -- you could place this here (if neccessary)

	   local humanoid = gear.Parent:FindFirstChildWhichIsA('Humanoid')

	   if not cooldown then -- shortened
		    cooldown = true
		    local loadedAnim = humanoid:LoadAnimation(attackAnim)
		    loadedAnim:Play()
		    local canDamage = script.Parent.canDamage
		    canDamage.Value = true
		    wait(1)
		    loadedAnim:Stop()
		    canDamage.Value = false
			cooldown = false
		end	
	end)
end)
-- I also noticed that when you sent the Gui to the server, you never did anything with it

I don’t believe Frames support MouseButton1Down. Add a button to your UI (I suggest parenting it to the frame), and use this:
EDIT: I also recommend using the Activated event for UI rather than MouseButton1Down, but that’s just personal preference in case the player is on mobile

-- Local Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Testing = ReplicatedStorage:WaitForChild("DevKing?")

local Gui = game.Players.LocalPlayer.PlayerGui.OpenLightsaber

--[[ [pathtobutton].Activated:Connect(function() -- Replace [pathtobutton] with a path to the button
	Testing:FireServer()
end) -- This assumes the GUI is visible by default
--]]
-- Code above is for if you want to use a button press to fire the event, just remove the --[[ and --]] marks
-- Code below is for if you want the UI to appear when the tool is used
[pathtotool].Activated:Connect(function()
	Gui.Frame.Visible = true
	Testing:FireServer()
end)

-- Server Script

local gear = script.Parent
local attackAnim = script.attack
local tool = script.Parent
local cooldown = false
local Testing = game:GetService("ReplicatedStorage"):WaitForChild("DevKing?")

gear.Activated:Connect(function()
	Testing.OnServerEvent:Connect(function(player)
		local humanoid = gear.Parent:FindFirstChildOfClass("Humanoid")
		if not cooldown then
			cooldown = true
			local loadedAnim = humanoid:LoadAnimation(attackAnim)
			loadedAnim:Play()
			local canDamage = script.Parent.canDamage
			canDamage.Value = true
			wait(1)
			loadedAnim:Stop()
			canDamage.Value = false
			cooldown = false
		end	
	end)
end)

Question I already have two buttons under my frame so do I need to add it still? Also this code allows the script to connect with the GUI right?

If you want to use one of those buttons, then just path to whichever you want.
And I’m not exactly sure what you mean, but when you click with the tool in hand, the GUI will open and the server will be fired (with the uncommented code). If you want the frame to not be visible till the tool is used, I suggest parenting the buttons outside of the frame, and under the ScreenGui.
If those buttons aren’t supposed to be used to open the UI, then use the section of code for the LocalScript that isn’t commented out.
Note: I’m getting off for the night, so I can’t help you for a bit after this reply.