Argument 1 missing or nil?

Title says it all. I’m stumped.

Server script:

local EventFolder = game.ReplicatedStorage.HPRCRemotes

EventFolder.NameInput.OnServerEvent:Connect(function(plrName)
	local RequestedPlayer = game.Players:FindFirstChild(plrName) -- This is the line I'm getting it on
	
	EventFolder.GetToCranking:InvokeClient(RequestedPlayer)
end)

EventFolder.GetToCranking.OnServerInvoke = function(canTeleport)
	if canTeleport == true then
		print("yea yea")
	else
		print("oh crap")
	end
end

Local script, if that helps:

local EventFolder = game.ReplicatedStorage.HPRCRemotes
local Request = script.Parent.Request

local function countdown()
	timer = 30
	while wait(1) do
		if timer < 1 then
			break
		end

		timer = timer - 1
		print(timer)
	end
end

EventFolder.GetToCranking.OnClientInvoke = function(RequestedPlayer)
	local canTeleport = false
	Request.Visible = true
	
	local HurryUpNoob = coroutine.create(countdown)
	coroutine.resume(HurryUpNoob)
	
	Request.Accept.MouseButton1Click:Connect(function(player)
		canTeleport = true
		coroutine.yield(HurryUpNoob)
		timer = 30
		
		return canTeleport
	end)
	
	Request.Deny.MouseButton1Click:Connect(function()
		canTeleport = false
		coroutine.yield(HurryUpNoob)
		timer = 30
		
		return canTeleport
	end)
end

Also, I don’t think I’m using RemoteFunctions correctly either. Sooo, let me know if I messed up anywhere?

First parameter of OnServerEvent is the player who fired the event, change it to

EventFolder.NameInput.OnServerEvent:Connect(function(plr,plrName)
	local RequestedPlayer = game.Players:FindFirstChild(plrName) 
	
	EventFolder.GetToCranking:InvokeClient(RequestedPlayer)
end)
1 Like