Remote event not firing

I’m making a turret and rn I’m trying to run a remote event that is a child of the turret but idk why its not working can someone help? The local script that is trying to find the remote event is inside a tool and the turret is inside a folder with the name of the player

inputService.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if equipp == true then
		if input.KeyCode == Enum.KeyCode.R then
			local mouse = player:GetMouse()
			local turret = workspace.Sentinels:FindFirstChild(player.Name):FindFirstChild("Turret")
			if turret then
				local changeTarget = turret:FindFirstChild("ChangeTarget")
				if mouse.Target then
					local target = mouse.Target.Parent:FindFirstChild("HumanoidRootPart")
					if target and changeTarget then
						changeTarget:FireServer(target)
						print(target)
					else
						print("missing something")
					end
				end
			else
				print(player.Name.." doesnt have a turret on")
			end
		end
	end
end)

I did all and the local script is in fact finding the remote event, i printed the remote event name, class, parent, all, so it is finding, but not firing, the problem is not the function of the event since its just a print rn

remoteEvent.OnServerEvent:Connect(function(player, mouseTarget)
	print("hello")
end)

and also, the script for the remote event is inside of the remote event, so its also in workspace

are any of these prints coming up?
image

1 Like

the print(target) is working, so its finding the target and the changetarget

okay, right here, the remote you are firing is called change turret.
image

is the remoteEvent in the server script called changeturret as well? is it the exact same remote the client is firing to?
image

1 Like

the server script for the event is inside the remote event, so i just get the remote event with script.Parent

okay thats quite weird, can you shwo me where the local script, and the server script are. show me the entire hierarchy. so show the whole thinglike this
image
so from the workspace till the script.

1 Like

Here it is, the script running the event is the child of the event, ignore its name
image

Are you having any errors?
It’s running well for me.

The LocalScript is called “Turret” for me here.

I set equipp to true in the normal Script. Perhaps you didn’t do that?

Did you set remoteEvent to script.Parent?


Please include the scripts with at least the variables if possible!

1 Like

equipp is true when the player holds the tool

i set remoteEvent to script.Parent on the server script that is a child of the remote event

im not having errors, the remote event just dont fire, all the print that should tell me that im having erros are not showing, just those who tell me that everything is fine

Just to confirm.
Is the tool in the player’s character whenever you are firing the remote?

1 Like

Had the same issue, and it’s really just Roblox Studio executing code in a weird order, basically local scripts load before server scripts or something like that, if you try it in-game it will work.

I am not sure if this is the case, but I suggest that you make sure

1 Like

yeh, the player is holding the tool

Guys, thank you to everyone who replied to this post; I’ve followed all of you. I managed to find the error in the script. I hadn’t mentioned it because I thought it was irrelevant, but now I see it was essential. Inside the remote event script, there was a while function checking for players near the part, and that was causing the problem. I thought the remote event would have priority over the while function, but apparently not. I placed the remote event above the while function, and then it worked. Thank you all, and sorry for the wasted time. @Bikereh @Sun_Battery23238 @Bikereh

1 Like

haha no worries. but while im here replying to you. instead of putting the remote event code above the loop, you can put the loop in a new thread. i would recommend you do it even if the loop is below the rest of you code. any code under the loop will stil run if its in a seperate thread. this is how you would do it:

task.spawn(function()
	
	while true do
		
		-- loop
		
	end
	
end)

RemoteEvent.OnServerEvent:Connect(function(Player)
	-- code
end)

quite simple really

If your problem is solved, mark your message as solved.

maybe it is firing but on the server script you have no events, do you have a printed statement on the server script?