I have a problem with the Remote Event

You can write your topic however you want, but you need to answer these questions:

  1. **What do you want to achieve?
    I want to complete this remote event function

  2. **What is the issue? It does not detect the event system but it is surely my mistake, I am still not very good at programming

  3. **What solutions have you tried so far? I was watching several videos to find the solution but Idid not find

localscript

local remote = game:GetService("ReplicatedStorage")
local remote1 = remote:WaitForChild("RemoteEvent")
local Character = script.Parent
local UserInputService = game:GetService("UserInputService")
local Light = Instance.new("PointLight", Character:WaitForChild("RightHand"))
local Light1 = Instance.new("PointLight", Character:WaitForChild("RightHand"))
local player = game.Players.LocalPlayer
local Anim1 = script:WaitForChild("Animation")
local hum = player.Character:WaitForChild("Humanoid")
local play = hum.Animator:LoadAnimation(Anim1)
local hand = player.Character:WaitForChild("RightHand")
local aKeyPressed = false
Light.Color = Color3.fromRGB(255, 255, 255)
Light.Enabled = false
Light.Brightness = 1.9
Light.Range = 10
Light.Shadows = true

Light1.Color = Color3.fromRGB(255, 255, 255)
Light1.Enabled = false
Light1.Brightness = 0.5
Light1.Range = 15
Light1.Shadows = false

function onKeyPress(inputObject, gameProcessedEvent)
	if not gameProcessedEvent then
		if inputObject.KeyCode == Enum.KeyCode.F then
			if Light.Enabled == false then
				hand.CastShadow = false
				hand.Material = Enum.Material.ForceField
				play:Play()
				play.Looped = true
				Light.Enabled = true
				Light1.Enabled = true
			else
				hand.Material = Enum.Material.Plastic
				play:Stop()
				play.Looped = false
				Light1.Enabled = false
				hand.CastShadow = true
				Light.Enabled = false
			end
		end
	end
end

UserInputService.InputBegan:Connect(onKeyPress)

remote1:FireServer(onKeyPress)

script

local remote = game:GetService("ReplicatedStorage")
local remote1 = remote:WaitForChild("RemoteEvent")

remote1.OnServerEvent:Connect(function(player, onKeyPress)
	
end)

image
texto en negrita

Think the issue is here you are sending the onkeypress function to the server with the event…?

if you are trying to fire the event when a key is pressed it needs to be inside your if statement above that
maybe in this if statement

if Light.Enabled == false then

when are you wanting it to fire to the server?

yes, what I am trying to do is that the lightpoint that has been created can be seen by the server or the other clients of the server, the script that I made is very badly done, I still have to learn a little more about that subject, but no I know if you could help me to give a solution to this problem?

You can do this a few ways.

one way is to create the lights on each character server side first then control server script by the remote function. could also control with a local script.

the below code could be used to setup the light instances on the server

		function SetupCharacterLights(Character)
			-- create the light instance for the character here
		end
		
		game.Players.PlayerAdded:Connect(function(Player)
			local Character = Player.Character or Player.CharacterAdded:Wait() -- get on initial
			SetupCharacterLights(Character) -- Initital setup
			
			Player.CharacterAdded:Connect(function()  -- resetup if character dies and/or respawns
				SetupCharacterLights(Character)
			end)
		end)

then in your local script you really only need to detect the keydown with this function move the rest to the server for changing light settings

		function onKeyPress(inputObject, gameProcessedEvent)
			if not gameProcessedEvent then
				if inputObject.KeyCode == Enum.KeyCode.F then
					remote1:FireServer()  -- just fire it for the server to toggle the lights   you could send over argument table for multi settings etc
				end
			end
		end

now in your server script on the remoteevent you need to do your light toggle/setting changes etc

Any errors about the output ?

Why do i keep doing the 30 letters thing ?