Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Remote event fires in studio but not in actual server?

--SERVER
commands.view = function(player,arguments)
	local playerSubject = findPlayer(arguments[1])
	print(playerSubject)
	if playerSubject ~= nil then
		viewEvent:FireClient(playerSubject)
	end
end

--CLIENT

viewEvent.OnClientEvent:Connect(function(playerSubject)
	print("viewing1")
	pcall(function() -- To make sure it doesn't throw an error.
		print("VIEWING2")
		cam.CameraSubject = playerSubject.Character
		wait(10)
		cam.CameraSubject = playerSubject.Character.Humanoid
	end)
end)

In studio it prints all of the prints, in an actual server it only prints the playerSubject and nothing else. I'm very confused on why it doesn't even print "viewing1"

1 answer

✓ Accepted answer

Firstly, when you are firing the viewEvent on the server, you are actually firing to the playerSubject and not the actual player. I am unsure if this is the functionality you wanted but I believe that this is the problem because on the client you take the "playerSubject" as an argument, but no arguments are passed through the RemoteEvent.

viewEvent:FireClient(player, playerSubject) -- firing to the player with the argument of playerSubject

The first argument that's required for :FireClient is the client you want to fire the event for, this argument is not passed through the event. However, any arguments you input after that are passed through and can be used by the client.

This discussion is preserved as it was. New answers, comments, and votes are closed.