RemoteEvents are not Firing at all, despite correct setup

I am currently working on a vehicle spawning system for my new game. All is working well, except that it doesn’t actually spawn anything, and I am getting absolutely no feedback from the output.

Basically, the way this system is supposed to work, is based on a LocalScript that manages player interaction with an NPC. Script detects when an NPC has been added to someone’s base, and the script handles interactions with player, like having the NPC wave at the player when a ProximityPrompt within the NPC is visible to the local player etc., and when the local player triggers the ProximityPrompt, the local script will open up the vehicle selection UI + change a value within said UI that is the remote, that when fired, will spawn the vehicle.

Here’s the relevant NPC code:

game.Workspace.tycoons.DescendantAdded:Connect(function(child)
	if child.Name == "vehicleSpawnNPC" then
		local data = {plrNear = false,dummy = child}
		chars[child] = data
		local head = child:WaitForChild("Head",10)
		local prox = head:WaitForChild("ProximityPrompt",3)
		if prox ~= nil then
			local playIt = child.Humanoid:LoadAnimation(animation)
			prox.PromptShown:Connect(function()
				chars[child].plrNear = true
				playIt:Play()
				playIt.Looped = true
				prox.PromptHidden:Wait()
				chars[child].plrNear = false
				playIt:Stop()
			end)
			prox.Triggered:Connect(function(player)
				print("success on the NPC")
				if player.PlayerGui.vehicleSelector.Enabled == false then
					player.PlayerGui.vehicleSelector.remoteLocation.Value = child:WaitForChild("remoteLocation",3).Value
					player.PlayerGui.vehicleSelector:SetAttribute("Type",child:GetAttribute("type"))
					player.PlayerGui.vehicleSelector.Enabled = true
				end
			end)
		end
	end
end)

and here is the relevant code for the vehicle spawning UI:

spawnButton.MouseButton1Down:Connect(function()
	if selectedVehicle ~= nil and script.Parent.remoteLocation.Value ~= nil then
		print("success on the UI click working")
		local remote = script.Parent.remoteLocation.Value
		remote:FireServer(selectedVehicle)
	end
end)

These scripts will both print the print statements that I have included in them. However, the print statement I have within a server script when the remote is fired by the above code never executes, and a vehicle is never spawned.

I have spent the last 2 or so hours trying a variety of ways to fix this, and absolutely nothing has fixed it. I have no idea what I am doing wrong.

i have a question

is ‘Value’ the remote?

script.Parent.remoteLocation.Value ~= nil

i’ve never seen a remote named value before that’s why i’m asking

Try iterating through each the tycoons’ descendants instead of using the DescendantAdded function. It could be that your function is never firing in the first place.

for i,v in pairs(workspace.tycoons:GetChildren()) do
	if v.Name == "vehicleSpawnNPC" then
		local data = {plrNear = false,dummy = child}
		chars[child] = data
		local head = child:WaitForChild("Head",10)
		local prox = head:WaitForChild("ProximityPrompt",3)
		if prox ~= nil then
			local playIt = child.Humanoid:LoadAnimation(animation)
			prox.PromptShown:Connect(function()
				chars[child].plrNear = true
				playIt:Play()
				playIt.Looped = true
				prox.PromptHidden:Wait()
				chars[child].plrNear = false
				playIt:Stop()
			end)
			prox.Triggered:Connect(function(player)
				print("success on the NPC")
				if player.PlayerGui.vehicleSelector.Enabled == false then
					player.PlayerGui.vehicleSelector.remoteLocation.Value = child:WaitForChild("remoteLocation",3).Value
					player.PlayerGui.vehicleSelector:SetAttribute("Type",child:GetAttribute("type"))
					player.PlayerGui.vehicleSelector.Enabled = true
				end
			end)
		end
	end
end

Ended up finding the solution. Apparently a module script in the script that detected when the remote was fired wasn’t loading correctly, but Output wouldn’t tell me that.

Thanks for those who tried helping though

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.